if (key == NULL) {
return false;
}
- found = gencache_get(key, NULL, &value, NULL);
+ found = gencache_get(key, ctx, &value, NULL);
TALLOC_FREE(key);
if (!found) {
return false;
}
TALLOC_FREE(*p_user_out);
- *p_user_out = talloc_strdup(ctx, value);
- SAFE_FREE(value);
+ *p_user_out = value;
if (!*p_user_out) {
return false;
}
DATA_BLOB blob;
bool ret = False;
- ret = gencache_get_data_blob(keystr, NULL, &blob, ptimeout, NULL);
+ ret = gencache_get_data_blob(keystr, mem_ctx, &blob, ptimeout, NULL);
if (!ret) {
return false;
}
return false;
}
if (value) {
- *value = SMB_STRDUP((char *)blob.data);
- data_blob_free(&blob);
- if (*value == NULL) {
- return false;
- }
+ *value = talloc_move(mem_ctx, (char **)&blob.data);
return true;
}
data_blob_free(&blob);
keystr = (char *)key.dptr;
} else {
/* ensure 0-termination */
- keystr = SMB_STRNDUP((char *)key.dptr, key.dsize);
+ keystr = talloc_strndup(talloc_tos(), (char *)key.dptr, key.dsize);
free_key = keystr;
+ if (keystr == NULL) {
+ goto done;
+ }
}
if (!gencache_pull_timeout((char *)data.dptr, &timeout, &endptr)) {
timeout, state->private_data);
done:
- SAFE_FREE(free_key);
+ TALLOC_FREE(free_key);
return 0;
}
valstr = (char *)value.data;
} else {
/* ensure 0-termination */
- valstr = SMB_STRNDUP((char *)value.data, value.length);
+ valstr = talloc_strndup(talloc_tos(), (char *)value.data, value.length);
free_val = valstr;
+ if (valstr == NULL) {
+ goto done;
+ }
}
DEBUG(10, ("Calling function with arguments "
state->fn(key, valstr, timeout, state->private_data);
- SAFE_FREE(free_val);
+ done:
+
+ TALLOC_FREE(free_val);
}
void gencache_iterate(void (*fn)(const char *key, const char *value,
if (key == NULL) {
return false;
}
- ret = gencache_get(key, NULL, &value, &timeout);
+ ret = gencache_get(key, talloc_tos(), &value, &timeout);
if (!ret) {
goto done;
}
done:
TALLOC_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return ret;
}
if (key == NULL) {
return false;
}
- ret = gencache_get(key, NULL, &value, &timeout);
+ ret = gencache_get(key, talloc_tos(), &value, &timeout);
TALLOC_FREE(key);
if (!ret) {
return false;
if (value[0] != '-') {
ret = string_to_sid(sid, value);
}
- SAFE_FREE(value);
+ TALLOC_FREE(value);
if (ret) {
*expired = (timeout <= time(NULL));
}
if (key == NULL) {
return false;
}
- ret = gencache_get(key, NULL, &value, &timeout);
+ ret = gencache_get(key, talloc_tos(), &value, &timeout);
TALLOC_FREE(key);
if (!ret) {
return false;
if (value[0] != '-') {
ret = string_to_sid(sid, value);
}
- SAFE_FREE(value);
+ TALLOC_FREE(value);
if (ret) {
*expired = (timeout <= time(NULL));
}
time_t timeout;
bool ret = true;
- if (!gencache_get(key, NULL, &sid_str, &timeout)) {
+ if (!gencache_get(key, mem_ctx, &sid_str, &timeout)) {
DEBUG(3, ("no entry: %s\n", key));
ret = false;
goto done;
if (key == NULL)
goto done;
- if (gencache_get(key, NULL, &value, NULL))
+ if (gencache_get(key, talloc_tos(), &value, NULL))
result = negative_conn_cache_valuedecode(value);
done:
DEBUG(9,("check_negative_conn_cache returning result %d for domain %s "
"server %s\n", NT_STATUS_V(result), domain, server));
TALLOC_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return result;
}
return False;
}
- if (!gencache_get(key, NULL, &value, &timeout)) {
+ if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
SAFE_FREE(key);
return False;
*num_names = ipstr_list_parse(value, ip_list);
SAFE_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return *num_names > 0; /* true only if some ip has been fetched */
}
if (!key)
return False;
- if (!gencache_get(key, NULL, &value, &timeout)) {
+ if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n",
key));
SAFE_FREE(key);
strlcpy(srvname_out, value, 16);
SAFE_FREE(key);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return True;
}
if (!key)
return False;
- if (!gencache_get(key, NULL, &value, &timeout)) {
+ if (!gencache_get(key, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("no entry for trusted domain %s found.\n", name));
SAFE_FREE(key);
return False;
/* convert sid string representation into struct dom_sid structure */
if(! string_to_sid(sid, value)) {
sid = NULL;
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return False;
}
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return True;
}
time_t timeout;
uint32 timestamp;
- if (!gencache_get(TDOMTSKEY, NULL, &value, &timeout)) {
+ if (!gencache_get(TDOMTSKEY, talloc_tos(), &value, &timeout)) {
DEBUG(5, ("no timestamp for trusted domain cache located.\n"));
SAFE_FREE(value);
return 0;
timestamp = atoi(value);
- SAFE_FREE(value);
+ TALLOC_FREE(value);
return timestamp;
}
goto done;
}
- if (gencache_get(cache_key, NULL, &cache_value, NULL)) {
+ if (gencache_get(cache_key, talloc_tos(), &cache_value, NULL)) {
uint32 tmp = strtoul(cache_value, NULL, 10);
*value = tmp;
ret = True;
done:
SAFE_FREE(cache_key);
- SAFE_FREE(cache_value);
+ TALLOC_FREE(cache_value);
return ret;
}
cache_key = talloc_asprintf(talloc_tos(), "PRINTERNAME/%s",
aprinter);
if ((cache_key != NULL) &&
- gencache_get(cache_key, NULL, &tmp, NULL)) {
+ gencache_get(cache_key, talloc_tos(), &tmp, NULL)) {
found = (strcmp(tmp, printer_not_found) != 0);
if (!found) {
DEBUG(4, ("Printer %s not found\n", aprinter));
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
return WERR_INVALID_PRINTER_NAME;
}
fstrcpy(sname, tmp);
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
}
/* Search all sharenames first as this is easier than pulling
return False;
}
- if (!gencache_get("foo", NULL, &val, &tm)) {
+ if (!gencache_get("foo", talloc_tos(), &val, &tm)) {
d_printf("%s: gencache_get() failed\n", __location__);
return False;
}
if (strcmp(val, "bar") != 0) {
d_printf("%s: gencache_get() returned %s, expected %s\n",
__location__, val, "bar");
- SAFE_FREE(val);
+ TALLOC_FREE(val);
return False;
}
- SAFE_FREE(val);
+ TALLOC_FREE(val);
if (!gencache_del("foo")) {
d_printf("%s: gencache_del() failed\n", __location__);
return False;
}
- if (gencache_get("foo", NULL, &val, &tm)) {
+ if (gencache_get("foo", talloc_tos(), &val, &tm)) {
d_printf("%s: gencache_get() on deleted entry "
"succeeded\n", __location__);
return False;
return False;
}
- if (!gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
+ if (!gencache_get_data_blob("foo", talloc_tos(), &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() failed\n", __location__);
return False;
}
return False;
}
- if (gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
+ if (gencache_get_data_blob("foo", talloc_tos(), &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() on deleted entry "
"succeeded\n", __location__);
return False;
__location__);
return false;
}
- if (gencache_get("blob", NULL, &val, &tm)) {
+ if (gencache_get("blob", talloc_tos(), &val, &tm)) {
d_printf("%s: gencache_get succeeded\n", __location__);
return false;
}
if (key == NULL) {
goto done;
}
- if (!gencache_get(key, NULL, &value, NULL)) {
+ if (!gencache_get(key, mem_ctx, &value, NULL)) {
goto done;
}
p = strchr(value, ' ');
TALLOC_FREE(dc_name);
TALLOC_FREE(dc_ip);
TALLOC_FREE(key);
+ TALLOC_FREE(value);
return ret;
}