Hi, Is it necessary to deallocate memory assigned using isc_mem_get() by explicitly using isc_mem_free()?
Ref: File builtin.c is available at ftp://1node.net/linux/bind-9.7.0b1/bin/named/*builtin*.*c*<ftp://1node.net/linux/bind-9.7.0b1/bin/named/builtin.c> Following is the code snippet: static isc_result_t builtin_create(const char *zone, int argc, char **argv,void *driverdata, void **dbdata) { ... builtin_t *empty; <-- Local variable. ... empty = *isc_mem_get*(ns_g_mctx, sizeof(*empty)); <-- Memory assigned using isc_mem_get server = isc_mem_strdup(ns_g_mctx, argv[1]); contact = isc_mem_strdup(ns_g_mctx, argv[2]); if (empty == NULL || server == NULL || contact == NULL) { *dbdata = &empty_builtin; if (server != NULL) isc_mem_free(ns_g_mctx, server); if (contact != NULL) isc_mem_free(ns_g_mctx, contact); if (empty != NULL) isc_mem_put(ns_g_mctx, empty, sizeof (*empty)); } ... } Here memory is assigned using isc_mem_get() however isc_mem_free() is conditional. Thus if conditions are false then there will be no isc_mem_free(). 1. Even if *builtin_t *empty; *is local to the function *builtin_create*, can it cause memory leak? 2. what should be the rerurn value of *isc_mem_strdup()* on success/failure? Regards, Kalpesh
_______________________________________________ bind-users mailing list bind-users@lists.isc.org https://lists.isc.org/mailman/listinfo/bind-users