您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ talloc_reference函数代码示例

51自学网 2021-06-03 08:39:52
  C++
这篇教程C++ talloc_reference函数代码示例写得很实用,希望能帮到您。

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

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

示例1: packet_send_callback

/*  put a packet in the send queue.  When the packet is actually sent,  call send_callback.    Useful for operations that must occur after sending a message, such  as the switch to SASL encryption after as sucessful LDAP bind relpy.*/_PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob,				       packet_send_callback_fn_t send_callback, 				       void *private_data){	struct send_element *el;	el = talloc(pc, struct send_element);	NT_STATUS_HAVE_NO_MEMORY(el);	DLIST_ADD_END(pc->send_queue, el, struct send_element *);	el->blob = blob;	el->nsent = 0;	el->send_callback = send_callback;	el->send_callback_private = private_data;	/* if we aren't going to free the packet then we must reference it	   to ensure it doesn't disappear before going out */	if (pc->nofree) {		if (!talloc_reference(el, blob.data)) {			return NT_STATUS_NO_MEMORY;		}	} else {		talloc_steal(el, blob.data);	}	if (private_data && !talloc_reference(el, private_data)) {		return NT_STATUS_NO_MEMORY;	}	TEVENT_FD_WRITEABLE(pc->fde);	return NT_STATUS_OK;}
开发者ID:AIdrifter,项目名称:samba,代码行数:39,


示例2: test_lifeless

static bool test_lifeless(const struct torture_context *ctx){	void *top = talloc_new(ctx);	char *parent, *child; 	void *child_owner = talloc_new(ctx);	parent = talloc_strdup(top, "parent");	if (!parent)		return false;	child = talloc_strdup(parent, "child");  	if (!child) {		talloc_free(parent);		return false;	}	if (!talloc_reference(child, parent)) {		talloc_free(parent);		return false;	}	if (!talloc_reference(child_owner, child)) {		talloc_unlink(child, parent);		talloc_free(parent);		return false;	}	talloc_unlink(top, parent);	talloc_free(child);	talloc_free(top);	talloc_free(child_owner);	talloc_free(child);	return true;}
开发者ID:HSchroeder,项目名称:ccan,代码行数:33,


示例3: talloc

struct context *context_new_defaults(struct clopts *o, void *context,                                     struct makefile *mf,                                     struct languagelist *ll,                                     struct contextstack *s){    struct context *c;    c = talloc(context, struct context);    c->type = CONTEXT_TYPE_DEFAULTS;    c->parent = NULL;    c->test_parent = NULL;    c->bin_dir = talloc_strdup(c, "bin");    c->lib_dir = talloc_strdup(c, "lib");    c->hdr_dir = talloc_asprintf(c, "%sinclude", o->source_path);    c->obj_dir = talloc_strdup(c, "obj");    c->src_dir = talloc_asprintf(c, "%ssrc", o->source_path);    c->chk_dir = talloc_strdup(c, "check");    c->tst_dir = talloc_asprintf(c, "%stest", o->source_path);    c->gen_dir = talloc_strdup(c, "obj/proc");    c->prefix = talloc_strdup(c, DEFAULT_PREFIX);    c->libexec_dir = talloc_strdup(c, "libexec");    c->share_dir = talloc_strdup(c, "share");    c->compile_opts = stringlist_new(c);    c->link_opts = stringlist_new(c);    c->shared_target = false;    c->mf = talloc_reference(c, mf);    c->ll = talloc_reference(c, ll);    c->s = s;    c->language = NULL;    c->autodeps = true;    return c;}
开发者ID:palmer-dabbelt,项目名称:pconfigure,代码行数:33,


示例4: test_talloc_free_in_destructor

static bool test_talloc_free_in_destructor(void){	void *level0;	void *level1;	void *level2;	void *level3;	void *level4;	void **level5;	printf("test: free_in_destructor/n# TALLOC FREE IN DESTRUCTOR/n");	level0 = talloc_new(NULL);	level1 = talloc_new(level0);	level2 = talloc_new(level1);	level3 = talloc_new(level2);	level4 = talloc_new(level3);	level5 = talloc(level4, void *);	*level5 = level3;	(void)talloc_reference(level0, level3);	(void)talloc_reference(level3, level3);	(void)talloc_reference(level5, level3);	talloc_set_destructor(level5, _test_talloc_free_in_destructor);	talloc_free(level1);	talloc_free(level0);	printf("success: free_in_destructor/n");	return true;}
开发者ID:urisimchoni,项目名称:samba,代码行数:32,


示例5: gensec_start

/**  Start the GENSEC system, returning a context pointer.  @param mem_ctx The parent TALLOC memory context.  @param gensec_security Returned GENSEC context pointer.  @note  The mem_ctx is only a parent and may be NULL.  @note, the auth context is moved to be a referenced pointer of the  @ gensec_security return */static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx, 			     struct tevent_context *ev,			     struct gensec_settings *settings, 			     struct auth_context *auth_context,			     struct gensec_security **gensec_security){	if (ev == NULL) {		DEBUG(0, ("No event context available!/n"));		return NT_STATUS_INTERNAL_ERROR;	}	(*gensec_security) = talloc_zero(mem_ctx, struct gensec_security);	NT_STATUS_HAVE_NO_MEMORY(*gensec_security);	(*gensec_security)->event_ctx = ev;	SMB_ASSERT(settings->lp_ctx != NULL);	(*gensec_security)->settings = talloc_reference(*gensec_security, settings);	/* We need to reference this, not steal, as the caller may be	 * python, which won't like it if we steal it's object away	 * from it */	(*gensec_security)->auth_context = talloc_reference(*gensec_security, auth_context);	return NT_STATUS_OK;}
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:33,


示例6: test_free_ref_null_context

static bool test_free_ref_null_context(void){	void *p1, *p2, *p3;	int ret;	talloc_disable_null_tracking();	p1 = talloc_new(NULL);	p2 = talloc_new(NULL);	p3 = talloc_reference(p2, p1);	torture_assert("reference", p3 == p1, "failed: reference on null");	ret = talloc_free(p1);	torture_assert("ref free with null parent", ret == 0, "failed: free with null parent");	talloc_free(p2);	talloc_enable_null_tracking_no_autofree();	p1 = talloc_new(NULL);	p2 = talloc_new(NULL);	p3 = talloc_reference(p2, p1);	torture_assert("reference", p3 == p1, "failed: reference on null");	ret = talloc_free(p1);	torture_assert("ref free with null tracked parent", ret == 0, "failed: free with null parent");	talloc_free(p2);	return true;}
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:29,


示例7: test_ref1

/*  test references */static bool test_ref1(void){	void *root, *p1, *p2, *ref, *r1;	printf("test: ref1/n# SINGLE REFERENCE FREE/n");	root = talloc_named_const(NULL, 0, "root");	p1 = talloc_named_const(root, 1, "p1");	p2 = talloc_named_const(p1, 1, "p2");	talloc_named_const(p1, 1, "x1");	talloc_named_const(p1, 2, "x2");	talloc_named_const(p1, 3, "x3");	r1 = talloc_named_const(root, 1, "r1");		ref = talloc_reference(r1, p2);	talloc_report_full(root, stderr);	CHECK_BLOCKS("ref1", p1, 5);	CHECK_BLOCKS("ref1", p2, 1);	CHECK_BLOCKS("ref1", ref, 1);	CHECK_BLOCKS("ref1", r1, 2);	fprintf(stderr, "Freeing p2/n");	talloc_unlink(r1, p2);	talloc_report_full(root, stderr);	CHECK_BLOCKS("ref1", p1, 5);	CHECK_BLOCKS("ref1", p2, 1);	CHECK_BLOCKS("ref1", r1, 1);	fprintf(stderr, "Freeing p1/n");	talloc_free(p1);	talloc_report_full(root, stderr);	CHECK_BLOCKS("ref1", r1, 1);	fprintf(stderr, "Freeing r1/n");	talloc_free(r1);	talloc_report_full(NULL, stderr);	fprintf(stderr, "Testing NULL/n");	if (talloc_reference(root, NULL)) {		return false;	}	CHECK_BLOCKS("ref1", root, 1);	CHECK_SIZE("ref1", root, 0);	talloc_free(root);	printf("success: ref1/n");	return true;}
开发者ID:urisimchoni,项目名称:samba,代码行数:56,


示例8: talloc_new

struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb, TALLOC_CTX *reference_ctx){	const void *p;	struct dsdb_schema *schema_out;	struct dsdb_schema *schema_in;	bool use_global_schema;	TALLOC_CTX *tmp_ctx = talloc_new(reference_ctx);	if (!tmp_ctx) {		return NULL;	}	/* see if we have a cached copy */	use_global_schema = dsdb_uses_global_schema(ldb);	if (use_global_schema) {		schema_in = global_schema;	} else {		p = ldb_get_opaque(ldb, "dsdb_schema");		schema_in = talloc_get_type(p, struct dsdb_schema);		if (!schema_in) {			talloc_free(tmp_ctx);			return NULL;		}	}	if (schema_in->refresh_fn && !schema_in->refresh_in_progress) {		if (!talloc_reference(tmp_ctx, schema_in)) {			/*			 * ensure that the schema_in->refresh_in_progress			 * remains valid for the right amount of time			 */			talloc_free(tmp_ctx);			return NULL;		}		schema_in->refresh_in_progress = true;		/* This may change schema, if it needs to reload it from disk */		schema_out = schema_in->refresh_fn(schema_in->loaded_from_module,						   schema_in,						   use_global_schema);		schema_in->refresh_in_progress = false;	} else {		schema_out = schema_in;	}	/* This removes the extra reference above */	talloc_free(tmp_ctx);	if (!reference_ctx) {		return schema_out;	} else {		return talloc_reference(reference_ctx, schema_out);	}}
开发者ID:sprymak,项目名称:samba,代码行数:52,


示例9: talloc_zero

/** * Create a sub torture context */struct torture_context *torture_context_child(struct torture_context *parent){    struct torture_context *subtorture = talloc_zero(parent, struct torture_context);    if (subtorture == NULL)        return NULL;    subtorture->ev = talloc_reference(subtorture, parent->ev);    subtorture->lp_ctx = talloc_reference(subtorture, parent->lp_ctx);    subtorture->outputdir = talloc_reference(subtorture, parent->outputdir);    subtorture->results = talloc_reference(subtorture, parent->results);    return subtorture;}
开发者ID:samba-team,项目名称:samba,代码行数:17,


示例10: dsdb_reference_schema

/** * Make this ldb use a specified schema, already fully calculated and belonging to another ldb */int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema,			  bool write_attributes){	int ret;	struct dsdb_schema *old_schema;	old_schema = ldb_get_opaque(ldb, "dsdb_schema");	ret = ldb_set_opaque(ldb, "dsdb_schema", schema);	if (ret != LDB_SUCCESS) {		return ret;	}	/* Remove the reference to the schema we just overwrote - if there was	 * none, NULL is harmless here */	talloc_unlink(ldb, old_schema);	if (talloc_reference(ldb, schema) == NULL) {		return ldb_oom(ldb);	}	/* Make this ldb use local schema preferably */	ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);	if (ret != LDB_SUCCESS) {		return ret;	}	ret = dsdb_schema_set_attributes(ldb, schema, write_attributes);	if (ret != LDB_SUCCESS) {		return ret;	}	return LDB_SUCCESS;}
开发者ID:sprymak,项目名称:samba,代码行数:35,


示例11: smb_krb5_get_keytab_container

krb5_error_code smb_krb5_get_keytab_container(TALLOC_CTX *mem_ctx,				struct smb_krb5_context *smb_krb5_context,				krb5_keytab opt_keytab,				const char *keytab_name,				struct keytab_container **ktc){	krb5_keytab keytab;	krb5_error_code ret;	if (opt_keytab) {		keytab = opt_keytab;	} else {		ret = krb5_kt_resolve(smb_krb5_context->krb5_context,						keytab_name, &keytab);		if (ret) {			DEBUG(1,("failed to open krb5 keytab: %s/n",				 smb_get_krb5_error_message(					smb_krb5_context->krb5_context,					ret, mem_ctx)));			return ret;		}	}	*ktc = talloc(mem_ctx, struct keytab_container);	if (!*ktc) {		return ENOMEM;	}	(*ktc)->smb_krb5_context = talloc_reference(*ktc, smb_krb5_context);	(*ktc)->keytab = keytab;	(*ktc)->password_based = false;	talloc_set_destructor(*ktc, free_keytab_container);	return 0;}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:35,


示例12: test_loop

static bool test_loop(void){	void *top = talloc_new(NULL);	char *parent;	struct req1 {		char *req2, *req3;	} *req1;	printf("test: loop/n# TALLOC LOOP DESTRUCTION/n");	parent = talloc_strdup(top, "parent");	req1 = talloc(parent, struct req1);	req1->req2 = talloc_strdup(req1, "req2");  	talloc_set_destructor(req1->req2, test_loop_destructor);	req1->req3 = talloc_strdup(req1, "req3");	(void)talloc_reference(req1->req3, req1);	talloc_report_full(top, stderr);	talloc_free(parent);	talloc_report_full(top, stderr);	talloc_report_full(NULL, stderr);	talloc_free(top);	torture_assert("loop", loop_destructor_count == 1, 				   "FAILED TO FIRE LOOP DESTRUCTOR/n");	loop_destructor_count = 0;	printf("success: loop/n");	return true;}
开发者ID:urisimchoni,项目名称:samba,代码行数:29,


示例13: auth_generate_session_info

_PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx, 				    struct tevent_context *event_ctx, 				    struct loadparm_context *lp_ctx,				    struct auth_serversupplied_info *server_info, 				    struct auth_session_info **_session_info) {	struct auth_session_info *session_info;	NTSTATUS nt_status;	session_info = talloc(mem_ctx, struct auth_session_info);	NT_STATUS_HAVE_NO_MEMORY(session_info);	session_info->server_info = talloc_reference(session_info, server_info);	/* unless set otherwise, the session key is the user session	 * key from the auth subsystem */ 	session_info->session_key = server_info->user_session_key;	nt_status = security_token_create(session_info,					  event_ctx,					  lp_ctx,					  server_info->account_sid,					  server_info->primary_group_sid,					  server_info->n_domain_groups,					  server_info->domain_groups,					  server_info->authenticated,					  &session_info->security_token);	NT_STATUS_NOT_OK_RETURN(nt_status);	session_info->credentials = NULL;	*_session_info = session_info;	return NT_STATUS_OK;}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:34,


示例14: test_ref3

/*  test references */static bool test_ref3(void){	void *root, *p1, *p2, *ref, *r1;	printf("test: ref3 [/nPARENT REFERENCE FREE/n]/n");	root = talloc_named_const(NULL, 0, "root");	p1 = talloc_named_const(root, 1, "p1");	p2 = talloc_named_const(root, 1, "p2");	r1 = talloc_named_const(p1, 1, "r1");	ref = talloc_reference(p2, r1);	talloc_report_full(root, stderr);	CHECK_BLOCKS("ref3", p1, 2);	CHECK_BLOCKS("ref3", p2, 2);	CHECK_BLOCKS("ref3", r1, 1);	fprintf(stderr, "Freeing p1/n");	talloc_free(p1);	talloc_report_full(root, stderr);	CHECK_BLOCKS("ref3", p2, 2);	CHECK_BLOCKS("ref3", r1, 1);	fprintf(stderr, "Freeing p2/n");	talloc_free(p2);	talloc_report_full(root, stderr);	CHECK_SIZE("ref3", root, 0);	talloc_free(root);	printf("success: ref3/n");	return true;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:38,


示例15: emsmdbp_source_key_from_fmid

_PUBLIC_ int emsmdbp_source_key_from_fmid(TALLOC_CTX *mem_ctx, struct emsmdbp_context *emsmdbp_ctx, const char *username, uint64_t fmid, struct Binary_r **source_keyP){	struct Binary_r	*source_key;	uint64_t	gc;	uint16_t	replid;	uint8_t		*bytes;	int		i;	replid = fmid & 0xffff;	source_key = talloc_zero(NULL, struct Binary_r);	source_key->cb = 22;	source_key->lpb = talloc_array(source_key, uint8_t, source_key->cb);	if (emsmdbp_replid_to_guid(emsmdbp_ctx, username, replid, (struct GUID *) source_key->lpb)) {		talloc_free(source_key);		return MAPISTORE_ERROR;	}	(void) talloc_reference(mem_ctx, source_key);	talloc_unlink(NULL, source_key);	gc = fmid >> 16;	bytes = source_key->lpb + 16;	for (i = 0; i < 6; i++) {		bytes[i] = gc & 0xff;		gc >>= 8;	}	*source_keyP = source_key;	return MAPISTORE_SUCCESS;}
开发者ID:EasyLinux,项目名称:Openchange,代码行数:32,


示例16: talloc_zero

/**  initialise a smb2_session structure */struct smb2_session *smb2_session_init(struct smb2_transport *transport,				       struct gensec_settings *settings,				       TALLOC_CTX *parent_ctx, bool primary){	struct smb2_session *session;	NTSTATUS status;	session = talloc_zero(parent_ctx, struct smb2_session);	if (!session) {		return NULL;	}	if (primary) {		session->transport = talloc_steal(session, transport);	} else {		session->transport = talloc_reference(session, transport);	}	session->pid = getpid();	/* prepare a gensec context for later use */	status = gensec_client_start(session, &session->gensec, 				     session->transport->socket->event.ctx, 				     settings);	if (!NT_STATUS_IS_OK(status)) {		talloc_free(session);		return NULL;	}	gensec_want_feature(session->gensec, GENSEC_FEATURE_SESSION_KEY);	return session;}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:35,


示例17: smb_krb5_context_set_event_ctx

krb5_error_code smb_krb5_context_set_event_ctx(struct smb_krb5_context *smb_krb5_context,					       struct tevent_context *ev,					       struct tevent_context **previous_ev){	int ret;	if (!ev) {		return EINVAL;	}	*previous_ev = smb_krb5_context->current_ev;	smb_krb5_context->current_ev = talloc_reference(smb_krb5_context, ev);	if (!smb_krb5_context->current_ev) {		return ENOMEM;	}	/* Set use of our socket lib */	ret = krb5_set_send_to_kdc_func(smb_krb5_context->krb5_context,					smb_krb5_send_and_recv_func,					ev);	if (ret) {		TALLOC_CTX *tmp_ctx = talloc_new(NULL);		DEBUG(1,("krb5_set_send_recv_func failed (%s)/n",			 smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, tmp_ctx)));		talloc_free(tmp_ctx);		talloc_unlink(smb_krb5_context, smb_krb5_context->current_ev);		smb_krb5_context->current_ev = NULL;		return ret;	}	return 0;}
开发者ID:dmitry-shavyrin,项目名称:samba4_embedded_build,代码行数:31,


示例18: parse_principal

static krb5_error_code parse_principal(TALLOC_CTX *parent_ctx,				       const char *princ_string,				       struct smb_krb5_context *smb_krb5_context,				       krb5_principal *princ,				       const char **error_string){	int ret;	struct principal_container *mem_ctx;	if (princ_string == NULL) {		 *princ = NULL;		 return 0;	}	ret = krb5_parse_name(smb_krb5_context->krb5_context,			      princ_string, princ);	if (ret) {		(*error_string) = smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, parent_ctx);		return ret;	}	mem_ctx = talloc(parent_ctx, struct principal_container);	if (!mem_ctx) {		(*error_string) = error_message(ENOMEM);		return ENOMEM;	}	/* This song-and-dance effectivly puts the principal	 * into talloc, so we can't loose it. */	mem_ctx->smb_krb5_context = talloc_reference(mem_ctx, smb_krb5_context);	mem_ctx->principal = *princ;	talloc_set_destructor(mem_ctx, free_principal);	return 0;}
开发者ID:Alexandr-Galko,项目名称:samba,代码行数:34,


示例19: cli_credentials_set_machine_account

/** * Obtain the client principal for this credentials context. * @param cred credentials context * @retval The username set on this context. * @note Return value will never be NULL except by programmer error. */const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_CTX *mem_ctx){	if (cred->machine_account_pending) {		cli_credentials_set_machine_account(cred);	}	if (cred->principal_obtained == CRED_CALLBACK && 	    !cred->callback_running) {	    	cred->callback_running = True;		cred->principal = cred->principal_cb(cred);	    	cred->callback_running = False;		cred->principal_obtained = CRED_SPECIFIED;	}	if (cred->principal_obtained < cred->username_obtained) {		if (cred->domain_obtained > cred->realm_obtained) {			return talloc_asprintf(mem_ctx, "%[email
C++ talloc_set_destructor函数代码示例
C++ talloc_new函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。