int populate_hash(GHashTable *h, const char * const path, tpath_type type, tpath_entry **pep) { int ret; char *key = NULL; tpath_entry *pe = NULL; pe = pentry_new(); if (! pe) { ret = -1; goto err; } pe->fd = -1; pe->filetype = type; pentry_set_path(pe, path); key = strdup(path); if (! key) { LOG(LOG_CRIT, "strdup(%s): %s", path, strerror(errno)); pentry_free(pe); ret = -1; goto err; } g_hash_table_insert(h, key, pe); ret = 0; err: if (pep) *pep = pe; return ret; }
static int populate_hash(GHashTable *h, const char * const path, pentry_t **pep) { int ret; char *key = NULL; pentry_t *pe = NULL; if (! pep) { ret = -1; goto err; } pe = pentry_new(); if (! pe) { ret = -1; goto err; } pentry_set_fd(pe, -1); pentry_set_path(pe, path); key = strdup(path); if (! key) { LOG(LOG_CRIT, "strdup(%s): %s", path, strerror(errno)); pentry_free(pe); ret = -1; goto err; } *pep = pe; g_hash_table_insert(h, key, pe); ret = 0; err: return ret; }