Cleanup: Use guarded allocator for data-block names returned from file reading
Direcly using the C library allocator functions is usually avoided in favor of our guarded allocator. It's more useful when debugging.
This commit is contained in:
parent
296bc35638
commit
2a4fe88c13
|
@ -148,7 +148,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
|
|||
}
|
||||
}
|
||||
|
||||
BLI_linklist_free(names, free);
|
||||
BLI_linklist_free(names, MEM_freeN);
|
||||
}
|
||||
|
||||
BLO_blendhandle_close(bh);
|
||||
|
|
|
@ -134,7 +134,7 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
|
|||
* \param bh: The blendhandle to access.
|
||||
* \param ofblocktype: The type of names to get.
|
||||
* \param tot_names: The length of the returned list.
|
||||
* \return A BLI_linklist of strings. The string links should be freed with malloc.
|
||||
* \return A BLI_linklist of strings. The string links should be freed with #MEM_freeN().
|
||||
*/
|
||||
LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, int *tot_names)
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
|
|||
if (bhead->code == ofblocktype) {
|
||||
const char *idname = blo_bhead_id_name(fd, bhead);
|
||||
|
||||
BLI_linklist_prepend(&names, strdup(idname + 2));
|
||||
BLI_linklist_prepend(&names, BLI_strdup(idname + 2));
|
||||
tot++;
|
||||
}
|
||||
else if (bhead->code == ENDB) {
|
||||
|
@ -254,7 +254,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
|
|||
* (e.g. "Scene", "Mesh", "Light", etc.).
|
||||
*
|
||||
* \param bh: The blendhandle to access.
|
||||
* \return A BLI_linklist of strings. The string links should be freed with malloc.
|
||||
* \return A BLI_linklist of strings. The string links should be freed with #MEM_freeN().
|
||||
*/
|
||||
LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
|
||||
{
|
||||
|
@ -272,7 +272,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
|
|||
const char *str = BKE_idtype_idcode_to_name(bhead->code);
|
||||
|
||||
if (BLI_gset_add(gathered, (void *)str)) {
|
||||
BLI_linklist_prepend(&names, strdup(str));
|
||||
BLI_linklist_prepend(&names, BLI_strdup(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2620,7 +2620,7 @@ static int filelist_readjob_list_lib(const char *root, ListBase *entries, const
|
|||
nbr_entries++;
|
||||
}
|
||||
|
||||
BLI_linklist_free(names, free);
|
||||
BLI_linklist_free(names, MEM_freeN);
|
||||
|
||||
return nbr_entries;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const
|
|||
printf("%s: error, found %d items, %d previews\n", __func__, nnames, nprevs);
|
||||
}
|
||||
BLI_linklist_free(previews, BKE_previewimg_freefunc);
|
||||
BLI_linklist_free(names, free);
|
||||
BLI_linklist_free(names, MEM_freeN);
|
||||
return ima;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const
|
|||
}
|
||||
|
||||
BLI_linklist_free(previews, BKE_previewimg_freefunc);
|
||||
BLI_linklist_free(names, free);
|
||||
BLI_linklist_free(names, MEM_freeN);
|
||||
}
|
||||
else {
|
||||
BlendThumbnail *data;
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
#include "BLO_readfile.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "bpy_capi_utils.h"
|
||||
#include "bpy_library.h"
|
||||
|
||||
|
@ -225,7 +227,7 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
|
|||
PyList_SET_ITEM(list, counter, PyUnicode_FromString((char *)l->link));
|
||||
counter++;
|
||||
}
|
||||
BLI_linklist_free(names, free); /* free linklist *and* each node's data */
|
||||
BLI_linklist_free(names, MEM_freeN); /* free linklist *and* each node's data */
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
Loading…
Reference in New Issue