mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	smtk-import reuse pre-existent code and fix leak
Use update_event_name() for bookmarks merge and free temp string. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
This commit is contained in:
		
							parent
							
								
									329a6bc075
								
							
						
					
					
						commit
						75007aa4ef
					
				
					 1 changed files with 4 additions and 4 deletions
				
			
		|  | @ -687,15 +687,15 @@ static void smtk_parse_bookmarks(MdbHandle *mdb, struct dive *d, char *dive_idx) | ||||||
| 			time = lrint(strtod(col[4]->bind_ptr, NULL) * 60); | 			time = lrint(strtod(col[4]->bind_ptr, NULL) * 60); | ||||||
| 			tmp = strdup(col[2]->bind_ptr); | 			tmp = strdup(col[2]->bind_ptr); | ||||||
| 			ev = find_bookmark(d->dc.events, time); | 			ev = find_bookmark(d->dc.events, time); | ||||||
| 			if (ev != NULL) { | 			if (ev) | ||||||
| 				memset(&ev->name, 0, strlen(tmp) + 1); | 				update_event_name(d, ev, tmp); | ||||||
| 				memcpy(ev->name, tmp, strlen(tmp)); | 			else | ||||||
| 			} else |  | ||||||
| 				if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp)) | 				if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp)) | ||||||
| 					report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s", | 					report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s", | ||||||
| 						     d->number, tmp); | 						     d->number, tmp); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	free(tmp); | ||||||
| 	smtk_free(bound_values, table->num_cols); | 	smtk_free(bound_values, table->num_cols); | ||||||
| 	mdb_free_tabledef(table); | 	mdb_free_tabledef(table); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue