本文整理汇总了C++中dpl_dict_free函数的典型用法代码示例。如果您正苦于以下问题:C++ dpl_dict_free函数的具体用法?C++ dpl_dict_free怎么用?C++ dpl_dict_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dpl_dict_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dpl_cdmi_head
dpl_status_t
dpl_cdmi_head(dpl_ctx_t *ctx,
const char *bucket,
const char *resource,
const char *subresource,
const dpl_option_t *option,
dpl_ftype_t object_type,
const dpl_condition_t *condition,
dpl_dict_t **metadatap,
dpl_sysmd_t *sysmdp,
char **locationp)
{
int ret, ret2;
dpl_dict_t *all_mds = NULL;
dpl_dict_t *metadata = NULL;
DPL_TRACE(ctx, DPL_TRACE_BACKEND, "");
ret2 = dpl_cdmi_head_raw(ctx, bucket, resource, subresource, option, object_type, condition, &all_mds, locationp);
if (DPL_SUCCESS != ret2)
{
ret = ret2;
goto end;
}
ret2 = dpl_cdmi_get_metadata_from_values(all_mds, &metadata, sysmdp);
if (DPL_SUCCESS != ret2)
{
ret = ret2;
goto end;
}
if (NULL != metadatap)
{
*metadatap = metadata;
metadata = NULL;
}
ret = DPL_SUCCESS;
end:
if (NULL != metadata)
dpl_dict_free(metadata);
if (NULL != all_mds)
dpl_dict_free(all_mds);
DPL_TRACE(ctx, DPL_TRACE_BACKEND, "ret=%d", ret);
return ret;
}
示例2: dpl_cdmi_head
dpl_status_t
dpl_cdmi_head(dpl_ctx_t *ctx,
const char *bucket,
const char *resource,
const char *subresource,
dpl_ftype_t object_type,
const dpl_condition_t *condition,
dpl_dict_t **metadatap)
{
int ret, ret2;
dpl_dict_t *all_mds = NULL;
dpl_dict_t *metadata = NULL;
ret2 = dpl_cdmi_head_all(ctx, bucket, resource, subresource, object_type, condition, &all_mds);
if (DPL_SUCCESS != ret2)
{
ret = ret2;
goto end;
}
metadata = dpl_dict_new(13);
if (NULL == metadata)
{
ret = DPL_ENOMEM;
goto end;
}
ret2 = dpl_cdmi_get_metadata_from_json_metadata(all_mds, metadata);
if (DPL_SUCCESS != ret2)
{
ret = DPL_FAILURE;
goto end;
}
if (NULL != metadatap)
{
*metadatap = metadata;
metadata = NULL;
}
ret = DPL_SUCCESS;
end:
if (NULL != metadata)
dpl_dict_free(metadata);
if (NULL != all_mds)
dpl_dict_free(all_mds);
return ret;
}
示例3: dpl_s3_delete_all
dpl_status_t
dpl_s3_delete_all(dpl_ctx_t *ctx,
const char *bucket,
dpl_locators_t *locators,
UNUSED const dpl_option_t *option,
UNUSED const dpl_condition_t *condition,
dpl_vec_t **objectsp)
{
dpl_status_t ret;
struct dall_req dctx = {
.req = NULL,
.headers = NULL,
.conn = NULL,
.data = NULL,
.answer_data = NULL,
.answer_len = 0,
.connection_close = 0,
.objects = NULL,
};
ret = delete_all(ctx, bucket, locators, &dctx, objectsp);
if (dctx.conn != NULL) {
if (dctx.connection_close)
dpl_conn_terminate(dctx.conn);
else
dpl_conn_release(dctx.conn);
}
if (dctx.headers != NULL)
dpl_dict_free(dctx.headers);
if (dctx.query_params)
dpl_dict_free(dctx.query_params);
if (dctx.req != NULL)
dpl_req_free(dctx.req);
if (dctx.data != NULL)
dpl_sbuf_free(dctx.data);
if (dctx.answer_data != NULL)
free(dctx.answer_data);
if (dctx.objects != NULL)
dpl_vec_delete_objects_free(dctx.objects);
return ret;
}
示例4: dpl_posix_stream_getmd
dpl_status_t
dpl_posix_stream_getmd(dpl_ctx_t *ctx,
dpl_stream_t *stream,
dpl_dict_t **metadatap,
dpl_sysmd_t **sysmdp)
{
dpl_dict_t *all_mds = NULL;
dpl_status_t ret = DPL_FAILURE;
DPL_TRACE(ctx, DPL_TRACE_BACKEND, "");
ret = dpl_posix_head_raw(ctx, stream->bucket, stream->locator,
NULL, NULL, DPL_FTYPE_REG, NULL,
&all_mds, NULL);
if (DPL_SUCCESS != ret)
goto end;
ret = dpl_posix_get_metadata_from_values(all_mds,
metadatap,
sysmdp ? *sysmdp : NULL);
if (DPL_SUCCESS != ret)
goto end;
ret = DPL_SUCCESS;
end:
if (all_mds)
dpl_dict_free(all_mds);
DPL_TRACE(ctx, DPL_TRACE_BACKEND, "ret=%d", ret);
return ret;
}
示例5: pentry_set_metadata
int
pentry_set_metadata(pentry_t *pe,
dpl_dict_t *dict)
{
int ret;
assert(pe);
if (pe->metadata)
dpl_dict_free(pe->metadata);
pe->metadata = dpl_dict_new(13);
if (! pe->metadata) {
LOG(LOG_ERR, "dpl_dict_new: can't allocate memory");
ret = -1;
goto err;
}
if (DPL_FAILURE == dpl_dict_copy(pe->metadata, dict)) {
ret = -1;
goto err;
}
ret = 0;
err:
return ret;
}
示例6: pentry_set_usermd
int
pentry_set_usermd(tpath_entry *pe,
dpl_dict_t *dict)
{
int ret;
assert(pe);
if (pe->usermd)
dpl_dict_free(pe->usermd);
pe->usermd = dpl_dict_new(13);
if (! pe->usermd) {
LOG(LOG_ERR, "path=%s: dpl_dict_new: can't allocate memory",
pe->path);
ret = -1;
goto err;
}
if (DPL_FAILURE == dpl_dict_copy(pe->usermd, dict)) {
LOG(LOG_ERR, "path=%s: dpl_dict_copy: failed", pe->path);
ret = -1;
goto err;
}
ret = 0;
err:
return ret;
}
示例7: teardown
static void
teardown(void)
{
if (ctx)
dpl_ctx_free(ctx);
dpl_dict_free(profile);
toyserver_stop(state);
dpl_free();
}
示例8: update_md
static void
update_md(gpointer data,
gpointer user_data)
{
pentry_t *pe = NULL;
char *path = NULL;
dpl_ftype_t type;
dpl_ino_t ino;
dpl_status_t rc;
dpl_dict_t *metadata = NULL;
struct list *dirent = NULL;
(void)user_data;
pe = data;
path = pentry_get_path(pe);
LOG(LOG_DEBUG, "path=%s", path);
ino = dpl_cwd(ctx, ctx->cur_bucket);
rc = dfs_namei_timeout(ctx, path, ctx->cur_bucket,
ino, NULL, NULL, &type);
LOG(LOG_DEBUG, "path=%s, dpl_namei: %s, type=%s",
path, dpl_status_str(rc), ftype_to_str(type));
if (DPL_SUCCESS != rc) {
LOG(LOG_NOTICE, "dfs_namei_timeout: %s", dpl_status_str(rc));
goto end;
}
rc = dfs_getattr_timeout(ctx, path, &metadata);
if (DPL_SUCCESS != rc && DPL_EISDIR != rc) {
LOG(LOG_ERR, "dfs_getattr_timeout: %s", dpl_status_str(rc));
goto end;
}
/* If this is a directory, update its entries' metadata */
if (DPL_FTYPE_DIR == type) {
dirent = pentry_get_dirents(pe);
if (dirent)
list_map(dirent, cb_map_dirents, pe);
}
if (pentry_md_trylock(pe))
goto end;
if (metadata)
pentry_set_metadata(pe, metadata);
pentry_set_atime(pe);
(void)pentry_md_unlock(pe);
end:
if (metadata)
dpl_dict_free(metadata);
}
示例9: cmd_setattr
int
cmd_setattr(int argc,
char **argv)
{
int ret;
char opt;
char *path = NULL;
dpl_dict_t *metadata = NULL;
var_set("status", "1", VAR_CMD_SET, NULL);
optind = 0;
while ((opt = getopt(argc, argv, usage_getoptstr(setattr_usage))) != -1)
switch (opt)
{
case 'm':
metadata = dpl_parse_metadata(optarg);
if (NULL == metadata)
{
fprintf(stderr, "error parsing metadata\n");
return SHELL_CONT;
}
break ;
case '?':
default:
usage_help(&setattr_cmd);
return SHELL_CONT;
}
argc -= optind;
argv += optind;
if (1 != argc)
{
usage_help(&setattr_cmd);
return SHELL_CONT;
}
path = argv[0];
ret = dpl_setattr(ctx, path, metadata);
if (DPL_SUCCESS != ret)
{
fprintf(stderr, "status: %s (%d)\n", dpl_status_str(ret), ret);
goto end;
}
var_set("status", "0", VAR_CMD_SET, NULL);
end:
if (NULL != metadata)
dpl_dict_free(metadata);
return SHELL_CONT;
}
示例10: dpl_profile_free
void
dpl_profile_free(dpl_ctx_t *ctx)
{
dpl_conn_pool_destroy(ctx);
dpl_close_event_log(ctx);
if (NULL != ctx->pricing)
dpl_pricing_free(ctx);
if (1 == ctx->use_https)
{
SSL_CTX_free(ctx->ssl_ctx);
BIO_vfree(ctx->ssl_bio_err);
}
/*
* profile
*/
if (NULL != ctx->addrlist)
dpl_addrlist_free(ctx->addrlist);
if (NULL != ctx->base_path)
free(ctx->base_path);
if (NULL != ctx->access_key)
free(ctx->access_key);
if (NULL != ctx->secret_key)
free(ctx->secret_key);
if (NULL != ctx->ssl_cert_file)
free(ctx->ssl_cert_file);
if (NULL != ctx->ssl_key_file)
free(ctx->ssl_key_file);
if (NULL != ctx->ssl_password)
free(ctx->ssl_password);
if (NULL != ctx->ssl_ca_list)
free(ctx->ssl_ca_list);
if (NULL != ctx->pricing)
free(ctx->pricing);
if (NULL != ctx->encrypt_key)
free(ctx->encrypt_key);
if (NULL != ctx->pricing_dir)
free(ctx->pricing_dir);
/**/
if (NULL != ctx->droplet_dir)
free(ctx->droplet_dir);
if (NULL != ctx->profile_name)
free(ctx->profile_name);
if (NULL != ctx->cwds)
dpl_dict_free(ctx->cwds);
if (NULL != ctx->cur_bucket)
free(ctx->cur_bucket);
}
示例11: START_TEST
END_TEST
START_TEST(remove_test)
{
dpl_dict_t *dict;
int i;
dpl_status_t r;
char valbuf[128];
/* create with a small table to ensure we have some chains */
dict = dpl_dict_new(5);
dpl_assert_ptr_not_null(dict);
/* add all the keys */
for (i = 0 ; i < nkeys ; i++)
{
dpl_dict_add(dict, keys[i],
make_value(i, valbuf, sizeof(valbuf)),
/* lowered */0);
}
dpl_assert_int_eq(nkeys, dpl_dict_count(dict));
/* remove the keys again */
for (i = 0 ; i < nkeys ; i++)
{
dpl_dict_var_t *var = dpl_dict_get(dict, keys[i]);
dpl_assert_ptr_not_null(var);
dpl_assert_str_eq(var->key, keys[i]);
dpl_dict_remove(dict, var);
dpl_assert_int_eq(nkeys-1-i, dpl_dict_count(dict));
}
/* add all the keys back again */
for (i = 0 ; i < nkeys ; i++)
{
dpl_dict_add(dict, keys[i],
make_value(i, valbuf, sizeof(valbuf)),
/* lowered */0);
}
dpl_assert_int_eq(nkeys, dpl_dict_count(dict));
/* remove the keys again in reverse order; we do
* this to exercise some hash chain manipulation
* corner cases */
for (i = nkeys-1 ; i >= 0 ; i--)
{
dpl_dict_var_t *var = dpl_dict_get(dict, keys[i]);
dpl_assert_ptr_not_null(var);
dpl_assert_str_eq(var->key, keys[i]);
dpl_dict_remove(dict, var);
dpl_assert_int_eq(i, dpl_dict_count(dict));
}
dpl_dict_free(dict);
}
示例12: cb_map_dirents
static void
cb_map_dirents(void *elem, void *cb_arg)
{
char *path = NULL;
dpl_dict_t *metadata = NULL;
dpl_status_t rc;
dpl_ftype_t type;
dpl_ino_t ino, parent_ino, obj_ino;
pentry_t *pe_dirent = NULL;
pentry_t *pe = NULL;
path = elem;
pe = cb_arg;
LOG(LOG_DEBUG, "path='%s', dirent='%s'", path, pentry_get_path(pe));
pe_dirent = g_hash_table_lookup(hash, path);
if (! pe_dirent) {
LOG(LOG_ERR, "'%s' is not an entry anymore in '%s'",
path, pentry_get_path(pe));
goto end;
}
rc = dfs_namei_timeout(ctx, path, ctx->cur_bucket,
ino, &parent_ino, &obj_ino, &type);
LOG(LOG_DEBUG, "path=%s, dpl_namei: %s, type=%s, parent_ino=%s, obj_ino=%s",
path, dpl_status_str(rc), ftype_to_str(type),
parent_ino.key, obj_ino.key);
if (DPL_SUCCESS != rc) {
LOG(LOG_NOTICE, "dfs_namei_timeout: %s", dpl_status_str(rc));
goto end;
}
rc = dfs_getattr_timeout(ctx, path, &metadata);
if (DPL_SUCCESS != rc && DPL_EISDIR != rc) {
LOG(LOG_ERR, "dfs_getattr_timeout: %s", dpl_status_str(rc));
goto end;
}
if (pentry_md_trylock(pe_dirent))
goto end;
if (metadata)
pentry_set_metadata(pe_dirent, metadata);
pentry_set_atime(pe_dirent);
(void)pentry_md_unlock(pe_dirent);
end:
if (metadata)
dpl_dict_free(metadata);
}
示例13: dpl_cdmi_head_all
dpl_status_t
dpl_cdmi_head_all(dpl_ctx_t *ctx,
const char *bucket,
const char *resource,
const char *subresource,
dpl_ftype_t object_type,
const dpl_condition_t *condition,
dpl_dict_t **metadatap)
{
int ret, ret2;
char *md_buf = NULL;
u_int md_len;
dpl_dict_t *metadata = NULL;
//fetch metadata from JSON content
ret2 = dpl_cdmi_get(ctx, bucket, resource, NULL != subresource ? subresource : "metadata", object_type, condition, &md_buf, &md_len, NULL);
if (DPL_SUCCESS != ret2)
{
ret = DPL_FAILURE;
goto end;
}
metadata = dpl_dict_new(13);
if (NULL == metadata)
{
ret = DPL_ENOMEM;
goto end;
}
ret2 = dpl_cdmi_parse_metadata(ctx, md_buf, md_len, metadata);
if (DPL_SUCCESS != ret2)
{
ret = ret2;
goto end;
}
if (NULL != metadatap)
{
*metadatap = metadata;
metadata = NULL;
}
ret = DPL_SUCCESS;
end:
if (NULL != metadata)
dpl_dict_free(metadata);
if (NULL != md_buf)
free(md_buf);
return ret;
}
示例14: dpltest_upload_file
dpl_status_t
dpltest_upload_file(dpl_ctx_t *ctx,
char *path,
char *blob_buf,
int blob_size,
int buffered,
int block_size)
{
dpl_status_t ret, ret2;
dpl_canned_acl_t canned_acl = DPL_CANNED_ACL_PRIVATE;
dpl_dict_t *metadata = NULL;
int retries = 0;
dpl_sysmd_t sysmd;
memset(&sysmd, 0, sizeof (sysmd));
sysmd.mask = DPL_SYSMD_MASK_CANNED_ACL;
sysmd.canned_acl = canned_acl;
retry:
if (retries >= 3)
{
fprintf(stderr, "too many retries: %s (%d)\n", dpl_status_str(ret), ret);
ret = DPL_FAILURE;
goto end;
}
retries++;
//XXX buffered and block_size ignored for now
ret2 = dpl_fput(ctx, path, NULL, NULL, NULL, metadata, &sysmd, blob_buf, blob_size);
if (DPL_SUCCESS != ret2)
{
if (DPL_ENOENT == ret2)
{
ret = DPL_ENOENT;
}
goto retry;
}
ret = DPL_SUCCESS;
end:
if (NULL != metadata)
dpl_dict_free(metadata);
return ret;
}
示例15: dfs_readlink
int
dfs_readlink(const char *path,
char *buf,
size_t bufsiz)
{
dpl_dict_t *dict = NULL;
dpl_status_t rc;
int ret;
char *dest = NULL;
size_t dest_size = 0;
rc = dfs_getattr_timeout(ctx, path, &dict);
if (DPL_SUCCESS != rc) {
LOG(LOG_ERR, "dfs_getattr_timeout: %s", dpl_status_str(rc));
ret = -1;
goto err;
}
if (! dict) {
LOG(LOG_ERR, "dpl_getattr: %s", dpl_status_str(rc));
ret = -1;
goto err;
}
dest = dpl_dict_get_value(dict, "symlink");
if (! dest) {
LOG(LOG_ERR, "empty link path");
ret = -1;
goto err;
}
dest_size = strlen(dest);
if (dest_size > bufsiz) {
LOG(LOG_NOTICE, "link length too big: '%s'", dest);
dest_size = bufsiz;
}
if (! strncpy(buf, dest, dest_size)) {
LOG(LOG_ERR, "path=%s: strcpy: %s", path, strerror(errno));
ret = -1;
goto err;
}
ret = 0;
err:
if (dict)
dpl_dict_free(dict);
LOG(LOG_DEBUG, "%s", path);
return 0;
}