strdup in str_list.c: why strdup rather than e.g., dm_pool_strdup?
I noticed the use of strdup in str_list.c, and wondered why that code isn't using dm_pool_strdup, since the list structure itself is allocated via dm_pool_alloc(mem,...
Anyone know why?
int str_list_dup(struct dm_pool *mem, struct list *sllnew,
const struct list *sllold)
{
struct str_list *sl;
list_init(sllnew);
list_iterate_items(sl, sllold) {
if (!str_list_add(mem, sllnew, strdup(sl->str))) {
[[ why strdup here, and not "dm_pool_strdup(mem," ? ]]
stack;
return 0;
}
}
return 1;
}Quoted 3 lines · Jim Meyering
I noticed the use of strdup in
str_list.c, and wondered why that code isn't usingdm_pool_strdup, since the list structure itself is allocated via dm_pool_alloc(mem,...
(Note that this code dates from 2004.)strdup() should no longer be used (except in initialisation code):
we now have dm_strdup() instead that includes leak checking.
So firstly change it to dm_strdup().
Then the leak gets reported (eg pvdisplay a tagged PV).
So then change it to dm_pool_strdup() and things look OK.
Alasdair
Signature · 1 line
agk at redhat.com