lib/DtSvc: Free memory more soundly

It _probably_ works to just pass free(ptr) another two arguments, but
compilers don't like this kind of sloppiness anymore.
The call site only expects this function to free the first value,
ignoring the other two, so model that in the local wrapper function.
This commit is contained in:
Patrick Georgi
2025-12-17 20:06:21 +01:00
parent ae001c320f
commit aced075a9f

View File

@@ -151,13 +151,18 @@ _DtShmProtoInitStrtab(int sizeguess)
return((DtShmProtoStrtab) ptr); return((DtShmProtoStrtab) ptr);
} }
static int destroy_hashval(int *ptr, int *unused, unsigned char *unused2) {
free(ptr);
return 0;
}
int int
_DtShmProtoDestroyStrtab(DtShmProtoStrtab strlist) _DtShmProtoDestroyStrtab(DtShmProtoStrtab strlist)
{ {
strlist_t * ptr = (strlist_t *) strlist; strlist_t * ptr = (strlist_t *) strlist;
_DtUtilDestroyHash(ptr->sl_hash, NULL, NULL); _DtUtilDestroyHash(ptr->sl_hash, NULL, NULL);
_DtUtilDestroyHash(ptr->sl_bosons, (des_func)free, NULL); _DtUtilDestroyHash(ptr->sl_bosons, destroy_hashval, NULL);
free(ptr); free(ptr);
return(0); return(0);
} }