当前位置: 首页>>代码示例>>C++>>正文


C++ cf_free函数代码示例

本文整理汇总了C++中cf_free函数的典型用法代码示例。如果您正苦于以下问题:C++ cf_free函数的具体用法?C++ cf_free怎么用?C++ cf_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cf_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ai_findandset_imatch

int
ai_findandset_imatch(as_sindex_metadata *imd, as_sindex_pmetadata *pimd, int idx)
{
	if (!Num_tbls) {
		return AS_SINDEX_ERR;
	}

	char *tname = NULL, *cname = NULL, *iname = NULL;
	int ret = AS_SINDEX_OK;

	if (!(tname = create_tname_from_imd(imd))) {
		return AS_SINDEX_ERR_NO_MEMORY;
	}

	ret = AS_SINDEX_ERR;

	AI_GRLOCK();

	int tmatch = find_table(tname);
	if (tmatch == -1) {
		goto END;
	}
	if (imd->iname) {
		if (!(iname = get_iname_from_imd(imd))) {
			ret = AS_SINDEX_ERR_NO_MEMORY;
			goto END;
		}
		char idx_str[NAME_STR_LEN];
		snprintf(idx_str, sizeof(idx_str), "%d", idx);
		char *piname = str_concat(iname, '.', idx_str);
		pimd->imatch = match_partial_index_name(piname);
		cf_free(piname);
	} else {
		if (!(cname = create_cname_from_imd(imd))) {
			ret = AS_SINDEX_ERR_NO_MEMORY;
			goto END;
		}
		icol_t *ic = find_column(tmatch, cname);
		if (!ic) {
			goto END;
		}
		pimd->imatch = find_partial_index(tmatch, ic);
	}
	if (pimd->imatch == -1) {
		SITRACE(imd->si, META, debug, "Index%s: %s not found", imd->iname ? "" : "column-name", imd->iname ? iname : cname);
		goto END;
	}

	ret = AS_SINDEX_OK;

END:

	AI_UNLOCK();

	cf_free(tname);
	cf_free(iname);
	cf_free(cname);

	return ret;
}
开发者ID:LilyMat,项目名称:aerospike-server,代码行数:60,代码来源:ai_btree.c

示例2: cf_vector_destroy

void cf_vector_destroy(cf_vector *v) {
	if (v->flags & VECTOR_FLAG_BIGLOCK){
		pthread_mutex_destroy(&v->LOCK);
	}
	if (v->vector && (v->stack_vector == false))	cf_free(v->vector);
	if (v->stack_struct == false) cf_free(v);
}
开发者ID:shaobingxie,项目名称:aerospike-common,代码行数:7,代码来源:cf_vector.c

示例3: as_pair_fromval

char *as_pair_val_tostring(const as_val * v)
{
	as_pair * p = as_pair_fromval(v);
	if ( p == NULL ) return NULL;

	char * a = as_val_tostring(p->_1);
	size_t al = strlen(a);
	char * b = as_val_tostring(p->_2);
	size_t bl = strlen(b);
	
	size_t l = al + bl + 5;
	char * str = (char *) cf_malloc(sizeof(char) * l);
	if (!str) return str;

	strcpy(str, "(");
	strcpy(str+1, a);
	strcpy(str+1+al,", ");
	strcpy(str+1+al+2, b);
	strcpy(str+1+al+2+bl,")");
	*(str+1+al+2+bl+1) = '\0';
	
	cf_free(a);
	cf_free(b);

	return str;
}
开发者ID:respu,项目名称:aerospike-common,代码行数:26,代码来源:as_pair.c

示例4: reduced_iRem

/*
 * Delete operation for the nbtr does the following. Delete in the arr or nbtr
 * based on state of anbtr
 *
 * Parameter:   ibtr  : Btree of key
 *              acol  : Secondary index key
 *              apk   : value (primary key to be inserted)
 *
 * Returns:
 *      AS_SINDEX_OK           : In case of success
 *      AS_SINDEX_ERR          : In case of failure
 *      AS_SINDEX_KEY_NOTFOUND : If key does not exist
 */
static int
reduced_iRem(bt *ibtr, ai_obj *acol, ai_obj *apk)
{
	ai_nbtr *anbtr = (ai_nbtr *)btIndFind(ibtr, acol);
	ulong ba = 0, aa = 0;
	if (!anbtr) {
		return AS_SINDEX_KEY_NOTFOUND;
	}
	if (anbtr->is_btree) {
		if (!anbtr->u.nbtr) return AS_SINDEX_ERR;

		// Remove from nbtr if found
		bt *nbtr = anbtr->u.nbtr;
		if (!btIndNodeExist(nbtr, apk)) {
			return AS_SINDEX_KEY_NOTFOUND;
		}
		ba = nbtr->msize;

		// TODO - Needs to be cleaner, type convert from signed
		// to unsigned. Should be 64 bit !!
		int nkeys_before = nbtr->numkeys; 
		int nkeys_after = btIndNodeDelete(nbtr, apk, NULL);
		aa = nbtr->msize;

		if (nkeys_after == nkeys_before) {
			return AS_SINDEX_KEY_NOTFOUND;
		}

		// remove from ibtr
		if (nkeys_after == 0) {
			btIndDelete(ibtr, acol);
			aa = 0;
			bt_destroy(nbtr);
			ba += sizeof(ai_nbtr);
			cf_free(anbtr);
		}
	} else {
		if (!anbtr->u.arr) return AS_SINDEX_ERR;

		// Remove from arr if found
		bool notfound = false;
		ba = ai_arr_size(anbtr->u.arr);
		anbtr->u.arr = ai_arr_delete(anbtr->u.arr, (cf_digest *)&apk->y, &notfound);
		if (notfound) return AS_SINDEX_KEY_NOTFOUND;
		aa = ai_arr_size(anbtr->u.arr);

		// Remove from ibtr
		if (anbtr->u.arr->used == 0) {
			btIndDelete(ibtr, acol);
			aa = 0;
			ai_arr_destroy(anbtr->u.arr);
			ba += sizeof(ai_nbtr);
			cf_free(anbtr);
		}
	}
	ibtr->nsize -= (ba - aa);

	return AS_SINDEX_OK;
}
开发者ID:aerospike,项目名称:aerospike-server,代码行数:72,代码来源:ai_btree.c

示例5: as_roles_destroy

void
as_roles_destroy(as_role** roles, int roles_size)
{
    for (uint32_t i = 0; i < roles_size; i++) {
        cf_free(roles[i]);
    }
    cf_free(roles);
}
开发者ID:XeCycle,项目名称:aerospike-client-c,代码行数:8,代码来源:as_admin.c

示例6: as_users_destroy

void
as_users_destroy(as_user** users, int users_size)
{
    for (int i = 0; i < users_size; i++) {
        cf_free(users[i]);
    }
    cf_free(users);
}
开发者ID:XeCycle,项目名称:aerospike-client-c,代码行数:8,代码来源:as_admin.c

示例7: as_user_roles_destroy_array

void
as_user_roles_destroy_array(as_user_roles** user_roles, int user_roles_size)
{
	for (uint32_t i = 0; i < user_roles_size; i++) {
		cf_free(user_roles[i]);
	}
	cf_free(user_roles);
}
开发者ID:Benguang,项目名称:aerospike-client-c,代码行数:8,代码来源:as_admin.c

示例8: as_event_node_destroy

void
as_event_node_destroy(as_node* node)
{
	// Close connections.
	for (uint32_t i = 0; i < as_event_loop_size; i++) {
		as_ev_close_connections(node, &node->async_conn_qs[i]);
		as_ev_close_connections(node, &node->pipe_conn_qs[i]);
	}
	cf_free(node->async_conn_qs);
	cf_free(node->pipe_conn_qs);
}
开发者ID:BeeswaxIO,项目名称:aerospike-client-c,代码行数:11,代码来源:as_event_ev.c

示例9: as_vector_destroy

void
as_vector_destroy(as_vector* vector)
{
	if (vector->flags & FLAGS_HEAP) {
		cf_free(vector->list);
		
		if (vector->flags & FLAGS_CREATED) {
			cf_free(vector);
		}
	}
}
开发者ID:343829084,项目名称:aerospike-common,代码行数:11,代码来源:as_vector.c

示例10: as_event_executor_destroy

static inline void
as_event_executor_destroy(as_event_executor* executor)
{
    pthread_mutex_destroy(&executor->lock);

    if (executor->commands) {
        cf_free(executor->commands);
    }

    cf_free(executor);
}
开发者ID:XeCycle,项目名称:aerospike-client-c,代码行数:11,代码来源:as_event.c

示例11: reduced_iRem

/*
 * Delete operation for the nbtr does the following. Delete in the arr or nbtr
 * based on state of anbtr
 *
 * Parameter:   ibtr  : Btree of key
 *              acol  : Secondary index key
 *              apk   : value (primary key to be inserted)
 *
 * Returns:
 *      AS_SINDEX_OK           : In case of success
 *      AS_SINDEX_ERR          : In case of failure
 *      AS_SINDEX_KEY_NOTFOUND : If key does not exist
 */
static int
reduced_iRem(bt *ibtr, ai_obj *acol, ai_obj *apk)
{
	ai_nbtr *anbtr = (ai_nbtr *)btIndFind(ibtr, acol);
	ulong ba = 0, aa = 0;
	if (!anbtr) {
		return AS_SINDEX_ERR;
	}
	if (anbtr->is_btree) {
		if (!anbtr->u.nbtr) return AS_SINDEX_ERR;

		// Remove from nbtr if found
		bt *nbtr = anbtr->u.nbtr;
		if (!btIndNodeExist(nbtr, apk)) {
			return AS_SINDEX_KEY_NOTFOUND;
		}
		ba = nbtr->msize;
		int nkeys = btIndNodeDelete(nbtr, apk, NULL);
		aa = nbtr->msize;

		// remove from ibtr
		if (!nkeys) {
			btIndDelete(ibtr, acol);
			aa = 0;
			bt_destroy(nbtr);
			ba += sizeof(ai_nbtr);
			cf_free(anbtr);
		}
	} else {
		if (!anbtr->u.arr) return AS_SINDEX_ERR;

		// Remove from arr if found
		bool notfound = false;
		ba = ai_arr_size(anbtr->u.arr);
		anbtr->u.arr = ai_arr_delete(anbtr->u.arr, (cf_digest *)&apk->y, &notfound);
		if (notfound) return AS_SINDEX_KEY_NOTFOUND;
		aa = ai_arr_size(anbtr->u.arr);

		// Remove from ibtr
		if (anbtr->u.arr->used == 0) {
			btIndDelete(ibtr, acol);
			aa = 0;
			ai_arr_destroy(anbtr->u.arr);
			ba += sizeof(ai_nbtr);
			cf_free(anbtr);
		}
	}
	ibtr->nsize -= (ba - aa);

	return AS_SINDEX_OK;
}
开发者ID:LilyMat,项目名称:aerospike-server,代码行数:64,代码来源:ai_btree.c

示例12: cf_buf_builder_reserve_internal

//
// Make sure the buf has enough bytes for whatever you're up to.
int
cf_buf_builder_reserve_internal(cf_buf_builder **bb_r, size_t sz)
{
	cf_buf_builder *bb = *bb_r;

	// see if we need more space
	size_t new_sz = cf_dyn_buf_get_newsize(bb->alloc_sz, bb->used_sz, sz);
	if (new_sz > bb->alloc_sz) {
		if (bb->alloc_sz - bb->used_sz < MAX_BACKOFF) {
			bb = cf_realloc(bb, new_sz);
			if (!bb)	return(-1);
		}
		else {
			// Only possible if buffer was reset. Avoids potential expensive
			// copy within realloc.
			cf_buf_builder	*_t = cf_malloc(new_sz);
			if (!_t)	return(-1);
			memcpy(_t->buf, bb->buf, bb->used_sz);
			_t->used_sz = bb->used_sz;
			cf_free(bb);
			bb = _t;
		}
		bb->alloc_sz = new_sz - sizeof(cf_buf_builder);
		*bb_r = bb;
	}
	return(0);
}
开发者ID:BruceZhou2012,项目名称:aerospike-server,代码行数:29,代码来源:dynbuf.c

示例13: cf_dyn_buf_free

void
cf_dyn_buf_free(cf_dyn_buf *db)
{
	if (! db->is_stack && db->buf) {
		cf_free(db->buf);
	}
}
开发者ID:BruceZhou2012,项目名称:aerospike-server,代码行数:7,代码来源:dynbuf.c

示例14: udf_record_cache_free

void
udf_record_cache_free(udf_record * urecord)
{
	cf_debug(AS_UDF, "[ENTER] NumUpdates(%d) ", urecord->nupdates );

	for (uint32_t i = 0; i < urecord->nupdates; i ++ ) {
		udf_record_bin * bin = &urecord->updates[i];
		if ( bin->name[0] != '\0' && bin->value != NULL ) {
			bin->name[0] = '\0';
			as_val_destroy(bin->value);
			bin->value = NULL;
		}
		if ( bin->name[0] != '\0' && bin->oldvalue != NULL ) {
			bin->name[0] = '\0';
			as_val_destroy(bin->oldvalue);
			bin->oldvalue = NULL;
		}
	}

	for (uint32_t i = 0; i < UDF_RECORD_BIN_ULIMIT; i++) {
		if (urecord->updates[i].particle_buf) {
			cf_free(urecord->updates[i].particle_buf);
			urecord->updates[i].particle_buf = NULL;
		}
	}
	urecord->nupdates = 0;
	urecord->flag &= ~UDF_RECORD_FLAG_TOO_MANY_BINS;
}
开发者ID:farvour,项目名称:aerospike-server,代码行数:28,代码来源:udf_record.c

示例15: as_uv_connection_closed

static void
as_uv_connection_closed(uv_handle_t* socket)
{
	// socket->data has as_event_command ptr but that may have already been freed,
	// so free as_event_connection ptr by socket which is first field in as_event_connection.
	cf_free(socket);
}
开发者ID:BeeswaxIO,项目名称:aerospike-client-c,代码行数:7,代码来源:as_event_uv.c


注:本文中的cf_free函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。