void (*parser)(time_t timeout, DATA_BLOB blob,
void *private_data),
void *private_data);
-bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
+bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob,
time_t *timeout, bool *was_expired);
bool gencache_stabilize(void);
bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
* element.
*/
- exists = gencache_get_data_blob(keystr, &value, NULL, &was_expired);
+ exists = gencache_get_data_blob(keystr, NULL, &value, NULL,
+ &was_expired);
if (!exists && was_expired) {
/*
}
struct gencache_get_data_blob_state {
+ TALLOC_CTX *mem_ctx;
DATA_BLOB *blob;
time_t timeout;
bool result;
return;
}
- *state->blob = data_blob(blob.data, blob.length);
+ *state->blob = data_blob_talloc(state->mem_ctx, blob.data,
+ blob.length);
if (state->blob->data == NULL) {
state->result = false;
return;
* @retval False for failure
**/
-bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
+bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *blob,
time_t *timeout, bool *was_expired)
{
struct gencache_get_data_blob_state state;
bool expired = false;
state.result = false;
+ state.mem_ctx = mem_ctx;
state.blob = blob;
if (!gencache_parse(keystr, gencache_get_data_blob_parser, &state)) {
DATA_BLOB blob;
bool ret = False;
- ret = gencache_get_data_blob(keystr, &blob, ptimeout, NULL);
+ ret = gencache_get_data_blob(keystr, NULL, &blob, ptimeout, NULL);
if (!ret) {
return false;
}
return NT_STATUS_NO_MEMORY;
}
- if (!gencache_get_data_blob(key, &blob, NULL, NULL)) {
+ if (!gencache_get_data_blob(key, NULL, &blob, NULL, NULL)) {
return NT_STATUS_NOT_FOUND;
}
info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo);
if (!info) {
+ data_blob_free(&blob);
return NT_STATUS_NO_MEMORY;
}
return False;
}
- if (!gencache_get_data_blob("foo", &blob, NULL, NULL)) {
+ if (!gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() failed\n", __location__);
return False;
}
return False;
}
- if (gencache_get_data_blob("foo", &blob, NULL, NULL)) {
+ if (gencache_get_data_blob("foo", NULL, &blob, NULL, NULL)) {
d_printf("%s: gencache_get_data_blob() on deleted entry "
"succeeded\n", __location__);
return False;
return -1;
}
- if (gencache_get_data_blob(keystr, &value, &timeout, NULL)) {
+ if (gencache_get_data_blob(keystr, NULL, &value, &timeout, NULL)) {
print_cache_entry(keystr, value, timeout, NULL);
data_blob_free(&value);
return 0;