AmendHub

Download:

jcs

/

subtext

/

amendments

/

229

db: Better malloc notes


jcs made amendment 229 over 2 years ago
--- db.c Sun Jul 31 21:57:57 2022 +++ db.c Mon Aug 1 13:02:28 2022 @@ -436,6 +436,7 @@ db_cache_boards(struct db *tdb) short error; struct bile_object *obj; char *data = NULL; + char note[MALLOC_NOTE_SIZE]; if (tdb->boards) { for (n = 0; n < tdb->nboards; n++) { @@ -468,9 +469,10 @@ db_cache_boards(struct db *tdb) size = bile_read_alloc(tdb->bile, DB_BOARD_RTYPE, obj->id, &data); + snprintf(note, sizeof(note), "db_cache_boards %ld", obj->id); bile_unmarshall_object(tdb->bile, board_object_fields, nboard_object_fields, data, size, (char *)(&tdb->boards[n]), - sizeof(struct board), true); + sizeof(struct board), true, note); xfree(&data); } @@ -519,7 +521,7 @@ db_board_create(struct db *tdb, struct board *board) char *data; ret = bile_marshall_object(tdb->bile, board_object_fields, - nboard_object_fields, board, &data, &size); + nboard_object_fields, board, &data, &size, "db_board_create"); if (ret != 0 || size == 0) { warn("db_board_create: failed to marshall object"); return; @@ -556,6 +558,7 @@ db_cache_folders(struct db *tdb) unsigned long *ids; struct bile_object *obj; char *data = NULL; + char note[MALLOC_NOTE_SIZE]; if (tdb->folders) { for (n = 0; n < tdb->nfolders; n++) { @@ -587,9 +590,10 @@ db_cache_folders(struct db *tdb) break; size = bile_read_alloc(tdb->bile, DB_FOLDER_RTYPE, obj->id, &data); + snprintf(note, sizeof(note), "db_cache_folders %ld", obj->id); bile_unmarshall_object(tdb->bile, folder_object_fields, nfolder_object_fields, data, size, (char *)(&tdb->folders[n]), - sizeof(struct folder), true); + sizeof(struct folder), true, note); xfree(&data); } @@ -649,7 +653,7 @@ db_folder_create(struct db *tdb, struct folder *folder char *data; ret = bile_marshall_object(tdb->bile, folder_object_fields, - nfolder_object_fields, folder, &data, &size); + nfolder_object_fields, folder, &data, &size, "db_folder_create"); if (ret != 0 || size == 0) { warn("db_folder_create: failed to marshall object"); return;