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

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

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

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

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

示例1: pam_handle_cached_login

static void pam_handle_cached_login(struct pam_auth_req *preq, int ret,                                    time_t expire_date, time_t delayed_until){    uint32_t resp_type;    size_t resp_len;    uint8_t *resp;    int64_t dummy;    preq->pd->pam_status = cached_login_pam_status(ret);    switch (preq->pd->pam_status) {        case PAM_SUCCESS:            resp_type = SSS_PAM_USER_INFO_OFFLINE_AUTH;            resp_len = sizeof(uint32_t) + sizeof(int64_t);            resp = talloc_size(preq->pd, resp_len);            if (resp == NULL) {                DEBUG(SSSDBG_CRIT_FAILURE,                      "talloc_size failed, cannot prepare user info./n");            } else {                memcpy(resp, &resp_type, sizeof(uint32_t));                dummy = (int64_t) expire_date;                memcpy(resp+sizeof(uint32_t), &dummy, sizeof(int64_t));                ret = pam_add_response(preq->pd, SSS_PAM_USER_INFO, resp_len,                                       (const uint8_t *) resp);                if (ret != EOK) {                    DEBUG(SSSDBG_CRIT_FAILURE, "pam_add_response failed./n");                }            }            break;        case PAM_PERM_DENIED:            if (delayed_until >= 0) {                resp_type = SSS_PAM_USER_INFO_OFFLINE_AUTH_DELAYED;                resp_len = sizeof(uint32_t) + sizeof(int64_t);                resp = talloc_size(preq->pd, resp_len);                if (resp == NULL) {                    DEBUG(SSSDBG_CRIT_FAILURE,                          "talloc_size failed, cannot prepare user info./n");                } else {                    memcpy(resp, &resp_type, sizeof(uint32_t));                    dummy = (int64_t) delayed_until;                    memcpy(resp+sizeof(uint32_t), &dummy, sizeof(int64_t));                    ret = pam_add_response(preq->pd, SSS_PAM_USER_INFO, resp_len,                                           (const uint8_t *) resp);                    if (ret != EOK) {                        DEBUG(SSSDBG_CRIT_FAILURE,                              "pam_add_response failed./n");                    }                }            }            break;        default:            DEBUG(SSSDBG_TRACE_LIBS,                  "cached login returned: %d/n", preq->pd->pam_status);    }    pam_reply(preq);    return;}
开发者ID:nalind,项目名称:sssd,代码行数:58,


示例2: mapistore_get_queued_notifications_named

/**   /details Return the list of pending mapistore notifications   available on the queue name specified in argument.   /param mstore_ctx pointer to the mapistore context   /param mqueue_name the name of the queue to open   /param nl pointer on pointer to the list of mapistore notifications to return   /return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error. */_PUBLIC_ enum MAPISTATUS mapistore_get_queued_notifications_named(struct mapistore_context *mstore_ctx,								  const char *mqueue_name,								  struct mapistore_notification_list **nl){	int					ret;	mqd_t					mqueue;	struct mapistore_notification_list	*nlist = NULL;	struct mapistore_notification_list	*el = NULL;	unsigned int				prio;	struct mq_attr				attr;	DATA_BLOB				data;	bool					found = false;	printf("[%s:%d]: queue name = %s/n", __FUNCTION__, __LINE__, ((mqueue_name) ? mqueue_name : NULL));	/* Sanity checks */	MAPISTORE_RETVAL_IF(!mstore_ctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);	MAPISTORE_RETVAL_IF(!nl, MAPISTORE_ERR_INVALID_PARAMETER, NULL);	mqueue = mq_open(mqueue_name, O_RDONLY|O_NONBLOCK|O_CREAT, 0777, NULL);	if (mqueue == -1) {		perror("mq_open");		return MAPISTORE_ERR_NOT_INITIALIZED;	}	/* Retrieve queue attributes */	ret = mq_getattr(mqueue, &attr);	if (ret == -1) {		perror("mq_getattr");		/* set proper error message here and remove above */		if (mq_close(mqueue) == -1) {			perror("mq_close");		}		MAPISTORE_RETVAL_IF(ret == -1, MAPISTORE_ERR_NOT_FOUND, NULL);	}	data.data = talloc_size((TALLOC_CTX *)mstore_ctx, attr.mq_msgsize);	while ((data.length = mq_receive(mqueue, (char *)data.data, attr.mq_msgsize, &prio)) != -1) {		printf("* we received a notification on queue %s/n", mqueue_name);		if (!nlist) {			nlist = talloc_zero((TALLOC_CTX *)mstore_ctx, struct mapistore_notification_list);		}		el = mapistore_notification_process_mqueue_notif((TALLOC_CTX *)nlist, data);		printf("* processing notification returned %p/n", el);		if (el) {			DLIST_ADD_END(nlist, el, struct mapistore_notification_list);		}		talloc_free(data.data);		found = true;		data.data = talloc_size((TALLOC_CTX *)mstore_ctx, attr.mq_msgsize);	}
开发者ID:inverse-inc,项目名称:openchange.old,代码行数:60,


示例3: talloc_zero

struct tsocket_address *_tsocket_address_create(TALLOC_CTX *mem_ctx,						const struct tsocket_address_ops *ops,						void *pstate,						size_t psize,						const char *type,						const char *location){	void **ppstate = (void **)pstate;	struct tsocket_address *addr;	addr = talloc_zero(mem_ctx, struct tsocket_address);	if (!addr) {		return NULL;	}	addr->ops = ops;	addr->location = location;	addr->private_data = talloc_size(addr, psize);	if (!addr->private_data) {		talloc_free(addr);		return NULL;	}	talloc_set_name_const(addr->private_data, type);	*ppstate = addr->private_data;	return addr;}
开发者ID:gojdic,项目名称:samba,代码行数:26,


示例4: spoolss__op_ndr_pull

static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r){	enum ndr_err_code ndr_err;	uint16_t opnum = dce_call->pkt.u.request.opnum;	dce_call->fault_code = 0;	if (opnum >= ndr_table_spoolss.num_calls) {		dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;		return NT_STATUS_NET_WRITE_FAULT;	}	*r = talloc_size(mem_ctx, ndr_table_spoolss.calls[opnum].struct_size);	NT_STATUS_HAVE_NO_MEMORY(*r);        /* unravel the NDR for the packet */	ndr_err = ndr_table_spoolss.calls[opnum].ndr_pull(pull, NDR_IN, *r);	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {		dcerpc_log_packet(dce_call->conn->packet_log_dir,						  &ndr_table_spoolss, opnum, NDR_IN,				  &dce_call->pkt.u.request.stub_and_verifier);		dce_call->fault_code = DCERPC_FAULT_NDR;		return NT_STATUS_NET_WRITE_FAULT;	}	return NT_STATUS_OK;}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:27,


示例5: test_sinkdata

/*  test the SinkData interface*/static bool test_sinkdata(struct torture_context *tctx, 						  struct dcerpc_pipe *p){	int i;	NTSTATUS status;	uint8_t *data_in;	int len;	struct echo_SinkData r;	if (torture_setting_bool(tctx, "quick", false) &&	    (p->conn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) {		len = 100 + (random() % 5000);	} else {		len = 200000 + (random() % 5000);	}	data_in = talloc_size(tctx, len);	for (i=0;i<len;i++) {		data_in[i] = i+1;	}	r.in.len = len;	r.in.data = data_in;	status = dcerpc_echo_SinkData(p, tctx, &r);	torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, 										"SinkData(%d) failed", 							   len));	torture_comment(tctx, "sunk %d bytes/n", len);	return true;}
开发者ID:technosaurus,项目名称:samba4-GPL2,代码行数:35,


示例6: get_name_from_passwd_file

static char *get_name_from_passwd_file (void *ctx){    long pw_buf_size;    char *pw_buf;    struct passwd passwd, *ignored;    char *name;    int e;    pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);    if (pw_buf_size == -1) pw_buf_size = 64;    pw_buf = talloc_size (ctx, pw_buf_size);    while ((e = getpwuid_r (getuid (), &passwd, pw_buf,                            pw_buf_size, &ignored)) == ERANGE) {        pw_buf_size = pw_buf_size * 2;        pw_buf = talloc_zero_size(ctx, pw_buf_size);    }    if (e == 0) {	char *comma = strchr (passwd.pw_gecos, ',');	if (comma)	    name = talloc_strndup (ctx, passwd.pw_gecos,				   comma - passwd.pw_gecos);	else	    name = talloc_strdup (ctx, passwd.pw_gecos);    } else {	name = talloc_strdup (ctx, "");    }    talloc_free (pw_buf);    return name;}
开发者ID:markwalters1009,项目名称:notmuch,代码行数:34,


示例7: db_ctdb_ltdb_store

/* * Store a record together with the ctdb record header * in the local copy of the database. */static NTSTATUS db_ctdb_ltdb_store(struct db_ctdb_ctx *db,				   TDB_DATA key,				   struct ctdb_ltdb_header *header,				   TDB_DATA data){	TDB_DATA rec;	int ret;	rec.dsize = data.dsize + sizeof(struct ctdb_ltdb_header);	rec.dptr = (uint8_t *)talloc_size(talloc_tos(), rec.dsize);	if (rec.dptr == NULL) {		return NT_STATUS_NO_MEMORY;	}	memcpy(rec.dptr, header, sizeof(struct ctdb_ltdb_header));	memcpy(sizeof(struct ctdb_ltdb_header) + (uint8_t *)rec.dptr, data.dptr, data.dsize);	ret = tdb_store(db->wtdb->tdb, key, rec, TDB_REPLACE);	talloc_free(rec.dptr);	return (ret == 0) ? NT_STATUS_OK			  : tdb_error_to_ntstatus(db->wtdb->tdb);}
开发者ID:bud4,项目名称:samba,代码行数:30,


示例8: ctdb_dump_memory

/*  dump talloc memory hierarchy, returning it as a blob to the client */int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata){    /* dump to a file, then send the file as a blob */    FILE *f;    long fsize;    f = tmpfile();    if (f == NULL) {        DEBUG(DEBUG_ERR,(__location__ " Unable to open tmpfile - %s/n", strerror(errno)));        return -1;    }    talloc_report_full(NULL, f);    fsize = ftell(f);    if (fsize == -1) {        DEBUG(DEBUG_ERR, (__location__ " Unable to get file size - %s/n",                          strerror(errno)));        fclose(f);        return -1;    }    rewind(f);    outdata->dptr = talloc_size(outdata, fsize);    if (outdata->dptr == NULL) {        fclose(f);        CTDB_NO_MEMORY(ctdb, outdata->dptr);    }    outdata->dsize = fread(outdata->dptr, 1, fsize, f);    fclose(f);    if (outdata->dsize != fsize) {        DEBUG(DEBUG_ERR,(__location__ " Unable to read tmpfile/n"));        return -1;    }    return 0;}
开发者ID:jkerihuel,项目名称:samba,代码行数:35,


示例9: DEBUG

void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,                            uint32_t access_granted, size_t data_size,                            const char *type, NTSTATUS *pstatus){    struct policy *pol;    void *data;    if (p->pipe_handles->count > MAX_OPEN_POLS) {        DEBUG(0, ("policy_handle_create: ERROR: too many handles (%d) "                  "on pipe %s./n", (int)p->pipe_handles->count,                  get_pipe_name_from_syntax(talloc_tos(), &p->syntax)));        *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;        return NULL;    }    data = talloc_size(talloc_tos(), data_size);    if (data == NULL) {        *pstatus = NT_STATUS_NO_MEMORY;        return NULL;    }    talloc_set_name_const(data, type);    pol = create_policy_hnd_internal(p, hnd, data);    if (pol == NULL) {        TALLOC_FREE(data);        *pstatus = NT_STATUS_NO_MEMORY;        return NULL;    }    pol->access_granted = access_granted;    *pstatus = NT_STATUS_OK;    return data;}
开发者ID:b3rnik,项目名称:dsl-n55u-bender,代码行数:32,


示例10: base_type

glsl_type::glsl_type(const glsl_type *array, unsigned length) :   base_type(GLSL_TYPE_ARRAY),   sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),   sampler_type(0),   vector_elements(0), matrix_columns(0),   name(NULL), length(length){   this->fields.array = array;   /* Inherit the gl type of the base. The GL type is used for    * uniform/statevar handling in Mesa and the arrayness of the type    * is represented by the size rather than the type.    */   this->gl_type = array->gl_type;   /* Allow a maximum of 10 characters for the array size.  This is enough    * for 32-bits of ~0.  The extra 3 are for the '[', ']', and terminating    * NUL.    */   const unsigned name_length = strlen(array->name) + 10 + 3;   char *const n = (char *) talloc_size(this->mem_ctx, name_length);   if (length == 0)      snprintf(n, name_length, "%s[]", array->name);   else      snprintf(n, name_length, "%s[%u]", array->name, length);   this->name = n;}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:28,


示例11: sort_func

/*  add an integer into a record in sorted order*/static int sort_func(struct ctdb_call_info *call){	if (call->call_data == NULL ||	    call->call_data->dsize != sizeof(int)) {		return CTDB_ERR_INVALID;	}	call->new_data = talloc(call, TDB_DATA);	if (call->new_data == NULL) {		return CTDB_ERR_NOMEM;	}	call->new_data->dptr = talloc_size(call, 					   call->record_data.dsize + 					   call->call_data->dsize);	if (call->new_data->dptr == NULL) {		return CTDB_ERR_NOMEM;	}	call->new_data->dsize = call->record_data.dsize + call->call_data->dsize;	memcpy(call->new_data->dptr,	       call->record_data.dptr, call->record_data.dsize);	memcpy(call->new_data->dptr+call->record_data.dsize,	       call->call_data->dptr, call->call_data->dsize);	qsort(call->new_data->dptr, call->new_data->dsize / sizeof(int),	      sizeof(int), (comparison_fn_t)int_compare);	return 0;}
开发者ID:technosaurus,项目名称:samba4-GPL2,代码行数:30,


示例12: append_route

static void append_route(struct radius_ctx_st *pctx, const char *route, unsigned len){	unsigned i;	char *p;	/* accept route/mask */	if ((p=strchr(route, '/')) == 0)		return;	p = strchr(p, ' ');	if (p != NULL) {		len = p - route;	}	if (pctx->routes_size == 0) {		pctx->routes = talloc_size(pctx, sizeof(char*));	} else {		pctx->routes = talloc_realloc_size(pctx, pctx->routes,						   (pctx->routes_size+1)*sizeof(char*));	}	if (pctx->routes != NULL) {		i = pctx->routes_size;		pctx->routes[i] = talloc_strndup(pctx, route, len);		if (pctx->routes[i] != NULL)			pctx->routes_size++;	}}
开发者ID:fqtools,项目名称:ocserv,代码行数:28,


示例13: talloc_strdup

/*  convert a dom_sid to a string*/char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid){	int i, ofs, maxlen;	uint32_t ia;	char *ret;		if (!sid) {		return talloc_strdup(mem_ctx, "(NULL SID)");	}	maxlen = sid->num_auths * 11 + 25;	ret = (char *)talloc_size(mem_ctx, maxlen);	if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");	ia = (sid->id_auth[5]) +		(sid->id_auth[4] << 8 ) +		(sid->id_auth[3] << 16) +		(sid->id_auth[2] << 24);	ofs = snprintf(ret, maxlen, "S-%u-%lu", 		       (unsigned int)sid->sid_rev_num, (unsigned long)ia);	for (i = 0; i < sid->num_auths; i++) {		ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]);	}		return ret;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:31,


示例14: s3crypt_gen_salt

int s3crypt_gen_salt(TALLOC_CTX *memctx, char **_salt){    uint8_t rb[SALT_RAND_LEN];    char *salt, *cp;    size_t slen;    int ret;    ret = nspr_nss_init();    if (ret != EOK) {        return EIO;    }    salt = talloc_size(memctx, SALT_LEN_MAX + 1);    if (!salt) {        return ENOMEM;    }    ret = PK11_GenerateRandom(rb, SALT_RAND_LEN);    if (ret != SECSuccess) {        return EIO;    }    slen = SALT_LEN_MAX;    cp = salt;    b64_from_24bit(&cp, &slen, 4, rb[0], rb[1], rb[2]);    b64_from_24bit(&cp, &slen, 4, rb[3], rb[4], rb[5]);    b64_from_24bit(&cp, &slen, 4, rb[6], rb[7], rb[8]);    b64_from_24bit(&cp, &slen, 4, rb[9], rb[10], rb[11]);    *cp = '/0';    *_salt = salt;    return EOK;}
开发者ID:AbhishekKumarSingh,项目名称:sssd,代码行数:34,


示例15: offsetof

/*  form a ctdb_rec_data record from a key/data pair  note that header may be NULL. If not NULL then it is included in the data portion  of the record */static struct ctdb_rec_data *db_ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,							  TDB_DATA key, 						  struct ctdb_ltdb_header *header,						  TDB_DATA data){	size_t length;	struct ctdb_rec_data *d;	length = offsetof(struct ctdb_rec_data, data) + key.dsize + 		data.dsize + (header?sizeof(*header):0);	d = (struct ctdb_rec_data *)talloc_size(mem_ctx, length);	if (d == NULL) {		return NULL;	}	d->length = length;	d->reqid = reqid;	d->keylen = key.dsize;	memcpy(&d->data[0], key.dptr, key.dsize);	if (header) {		d->datalen = data.dsize + sizeof(*header);		memcpy(&d->data[key.dsize], header, sizeof(*header));		memcpy(&d->data[key.dsize+sizeof(*header)], data.dptr, data.dsize);	} else {		d->datalen = data.dsize;		memcpy(&d->data[key.dsize], data.dptr, data.dsize);	}	return d;}
开发者ID:gojdic,项目名称:samba,代码行数:34,


示例16: db_ntdb_fetchlock_parse

static enum NTDB_ERROR db_ntdb_fetchlock_parse(NTDB_DATA key, NTDB_DATA data,					       struct ntdb_fetch_locked_state *state){	struct db_record *result;	result = (struct db_record *)talloc_size(		state->mem_ctx,		sizeof(struct db_record) + key.dsize + data.dsize);	if (result == NULL) {		return NTDB_ERR_OOM;	}	state->result = result;	result->key.dsize = key.dsize;	result->key.dptr = ((uint8_t *)result) + sizeof(struct db_record);	memcpy(result->key.dptr, key.dptr, key.dsize);	result->value.dsize = data.dsize;	if (data.dsize > 0) {		result->value.dptr = result->key.dptr+key.dsize;		memcpy(result->value.dptr, data.dptr, data.dsize);	}	else {		result->value.dptr = NULL;	}	return NTDB_SUCCESS;}
开发者ID:AIdrifter,项目名称:samba,代码行数:30,


示例17: db_tdb_fetchlock_parse

static int db_tdb_fetchlock_parse(TDB_DATA key, TDB_DATA data,				  void *private_data){	struct tdb_fetch_locked_state *state =		(struct tdb_fetch_locked_state *)private_data;	struct db_record *result;	result = (struct db_record *)talloc_size(		state->mem_ctx,		sizeof(struct db_record) + key.dsize + data.dsize);	if (result == NULL) {		return 0;	}	state->result = result;	result->key.dsize = key.dsize;	result->key.dptr = ((uint8 *)result) + sizeof(struct db_record);	memcpy(result->key.dptr, key.dptr, key.dsize);	result->value.dsize = data.dsize;	if (data.dsize > 0) {		result->value.dptr = result->key.dptr+key.dsize;		memcpy(result->value.dptr, data.dptr, data.dsize);	}	else {		result->value.dptr = NULL;	}	return 0;}
开发者ID:ekohl,项目名称:samba,代码行数:32,


示例18: list_tail

static struct doc_section *new_section(struct list_head *list,				       const char *function,				       const char *type,				       unsigned int srcline){	struct doc_section *d;	char *lowertype;	unsigned int i;	/* If previous section was empty, delete it. */	d = list_tail(list, struct doc_section, list);	if (d && empty_section(d)) {		list_del(&d->list);		talloc_free(d);	}	d = talloc(list, struct doc_section);	d->function = function;	lowertype = talloc_size(d, strlen(type) + 1);	/* Canonicalize type to lower case. */	for (i = 0; i < strlen(type)+1; i++)		lowertype[i] = tolower(type[i]);	d->type = lowertype;	d->lines = NULL;	d->num_lines = 0;	d->srcline = srcline;	list_add_tail(list, &d->list);	return d;}
开发者ID:atbrox,项目名称:ccan,代码行数:30,


示例19: ldif_write_NDR

/*  use ndr_print_* to convert a NDR formatted blob to a ldif formatted blob  If mask_errors is true, then function succeeds but out data  is set to "<Unable to decode binary data>" message  /return 0 on success; -1 on error*/static int ldif_write_NDR(struct ldb_context *ldb, void *mem_ctx,			  const struct ldb_val *in, struct ldb_val *out,			  size_t struct_size,			  ndr_pull_flags_fn_t pull_fn,			  ndr_print_fn_t print_fn,			  bool mask_errors){	uint8_t *p;	enum ndr_err_code err;	if (!(ldb_get_flags(ldb) & LDB_FLG_SHOW_BINARY)) {		return ldb_handler_copy(ldb, mem_ctx, in, out);	}	p = talloc_size(mem_ctx, struct_size);	err = ndr_pull_struct_blob(in, mem_ctx, 				   p, pull_fn);	if (err != NDR_ERR_SUCCESS) {		/* fail in not in mask_error mode */		if (!mask_errors) {			return -1;		}		talloc_free(p);		out->data = (uint8_t *)talloc_strdup(mem_ctx, "<Unable to decode binary data>");		out->length = strlen((const char *)out->data);		return 0;	}	out->data = (uint8_t *)ndr_print_struct_string(mem_ctx, print_fn, "NDR", p);	talloc_free(p);	if (out->data == NULL) {		return ldb_handler_copy(ldb, mem_ctx, in, out);			}	out->length = strlen((char *)out->data);	return 0;}
开发者ID:atlant2011,项目名称:samba,代码行数:41,


示例20: DEBUG

void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,			    uint32_t access_granted, size_t data_size,			    const char *type, NTSTATUS *pstatus){	struct dcesrv_handle *rpc_hnd;	void *data;	if (p->pipe_handles->count > MAX_OPEN_POLS) {		DEBUG(0, ("ERROR: Too many handles (%d) for RPC connection %s/n",			  (int) p->pipe_handles->count,			  get_pipe_name_from_syntax(talloc_tos(),						    &p->contexts->syntax)));		*pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;		return NULL;	}	data = talloc_size(talloc_tos(), data_size);	if (data == NULL) {		*pstatus = NT_STATUS_NO_MEMORY;		return NULL;	}	talloc_set_name_const(data, type);	rpc_hnd = create_rpc_handle_internal(p, hnd, data);	if (rpc_hnd == NULL) {		TALLOC_FREE(data);		*pstatus = NT_STATUS_NO_MEMORY;		return NULL;	}	rpc_hnd->access_granted = access_granted;	*pstatus = NT_STATUS_OK;	return data;}
开发者ID:sprymak,项目名称:samba,代码行数:33,


示例21: ca_query_layout

static AudioChannelLayout* ca_query_layout(struct ao *ao,                                           AudioDeviceID device,                                           void *talloc_ctx){    OSStatus err;    uint32_t psize;    AudioChannelLayout *r = NULL;    AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {        .mSelector = kAudioDevicePropertyPreferredChannelLayout,        .mScope    = kAudioDevicePropertyScopeOutput,        .mElement  = kAudioObjectPropertyElementWildcard,    };    err = AudioObjectGetPropertyDataSize(device, &p_addr, 0, NULL, &psize);    CHECK_CA_ERROR("could not get device preferred layout (size)");    r = talloc_size(talloc_ctx, psize);    err = AudioObjectGetPropertyData(device, &p_addr, 0, NULL, &psize, r);    CHECK_CA_ERROR("could not get device preferred layout (get)");coreaudio_error:    return r;}
开发者ID:AppleNuts,项目名称:mpv,代码行数:25,


示例22: test_speed

/*  measure the speed of talloc versus malloc*/static bool test_speed(void){	void *ctx = talloc_new(NULL);	unsigned count;	const int loop = 1000;	int i;	struct timeval tv;	printf("test: speed [/nTALLOC VS MALLOC SPEED/n]/n");	tv = timeval_current();	count = 0;	do {		void *p1, *p2, *p3;		for (i=0;i<loop;i++) {			p1 = talloc_size(ctx, loop % 100);			p2 = talloc_strdup(p1, "foo bar");			p3 = talloc_size(p1, 300);			talloc_free(p1);		}		count += 3 * loop;	} while (timeval_elapsed(&tv) < 5.0);	fprintf(stderr, "talloc: %.0f ops/sec/n", count/timeval_elapsed(&tv));	talloc_free(ctx);	tv = timeval_current();	count = 0;	do {		void *p1, *p2, *p3;		for (i=0;i<loop;i++) {			p1 = malloc(loop % 100);			p2 = strdup("foo bar");			p3 = malloc(300);			free(p1);			free(p2);			free(p3);		}		count += 3 * loop;	} while (timeval_elapsed(&tv) < 5.0);	fprintf(stderr, "malloc: %.0f ops/sec/n", count/timeval_elapsed(&tv));	printf("success: speed/n");	return true;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:50,


示例23: get_pw_uid

static int get_pw_uid(TALLOC_CTX *mem_ctx,                      struct proxy_id_ctx *ctx,                      struct sysdb_ctx *sysdb,                      struct sss_domain_info *dom,                      uid_t uid){    TALLOC_CTX *tmpctx;    struct passwd *pwd;    enum nss_status status;    char *buffer;    size_t buflen;    bool del_user = false;    int ret;    DEBUG(SSSDBG_TRACE_FUNC, ("Searching user by uid (%d)/n", uid));    tmpctx = talloc_new(NULL);    if (!tmpctx) {        return ENOMEM;    }    pwd = talloc_zero(tmpctx, struct passwd);    if (!pwd) {        ret = ENOMEM;        goto done;    }    buflen = DEFAULT_BUFSIZE;    buffer = talloc_size(tmpctx, buflen);    if (!buffer) {        ret = ENOMEM;        goto done;    }    status = ctx->ops.getpwuid_r(uid, pwd, buffer, buflen, &ret);    ret = handle_getpw_result(status, pwd, dom, &del_user);    if (ret) {        DEBUG(SSSDBG_OP_FAILURE,              ("getpwuid failed [%d]: %s/n", ret, strerror(ret)));        goto done;    }    if (del_user) {        ret = delete_user(sysdb, dom, NULL, uid);        goto done;    }    ret = save_user(sysdb, dom, !dom->case_sensitive, pwd,                    pwd->pw_name, NULL, dom->user_timeout);done:    talloc_zfree(tmpctx);    if (ret) {        DEBUG(SSSDBG_CRIT_FAILURE,              ("proxy -> getpwuid_r failed for '%d' <%d>: %s/n",               uid, ret, strerror(ret)));    }    return ret;}
开发者ID:hujon,项目名称:sssd,代码行数:59,


示例24: talloc_size

/*  transport packet allocator - allows transport to control memory for packets*/static void *ctdb_tcp_allocate_pkt(TALLOC_CTX *mem_ctx, size_t size){    /* tcp transport needs to round to 8 byte alignment to ensure       that we can use a length header and 64 bit elements in       structures */    size = (size+(CTDB_TCP_ALIGNMENT-1)) & ~(CTDB_TCP_ALIGNMENT-1);    return talloc_size(mem_ctx, size);}
开发者ID:miguelinux,项目名称:samba,代码行数:11,


示例25: initialise_output_state

static void initialise_output_state(TALLOC_CTX *mem_ctx, output_state *state, uint32_t rawSize, DATA_BLOB *output_blob){	state->out_pos = 0;	state->out_size = rawSize + LZFU_HEADERLENGTH + 4;	output_blob->data = (uint8_t *) talloc_size(mem_ctx, state->out_size);	output_blob->length = 0;	state->output_blob = output_blob;}
开发者ID:ThHirsch,项目名称:openchange,代码行数:8,


示例26: queue_process

/* * This function is used to process data in queue buffer. * * Queue callback function can end up freeing the queue, there should not be a * loop processing packets from queue buffer.  Instead set up a timed event for * immediate run to process remaining packets from buffer. */static void queue_process(struct ctdb_queue *queue){	uint32_t pkt_size;	uint8_t *data;	if (queue->buffer.length < sizeof(pkt_size)) {		return;	}	pkt_size = *(uint32_t *)queue->buffer.data;	if (pkt_size == 0) {		DEBUG(DEBUG_CRIT, ("Invalid packet of length 0/n"));		goto failed;	}	if (queue->buffer.length < pkt_size) {		if (pkt_size > QUEUE_BUFFER_SIZE) {			queue->buffer.extend = pkt_size;		}		return;	}	/* Extract complete packet */	data = talloc_size(queue, pkt_size);	if (data == NULL) {		DEBUG(DEBUG_ERR, ("read error alloc failed for %u/n", pkt_size));		return;	}	memcpy(data, queue->buffer.data, pkt_size);	/* Shift packet out from buffer */	if (queue->buffer.length > pkt_size) {		memmove(queue->buffer.data,			queue->buffer.data + pkt_size,			queue->buffer.length - pkt_size);	}	queue->buffer.length -= pkt_size;	if (queue->buffer.length > 0) {		/* There is more data to be processed, schedule an event */		tevent_schedule_immediate(queue->im, queue->ctdb->ev,					  queue_process_event, queue);	} else {		if (queue->buffer.size > QUEUE_BUFFER_SIZE) {			TALLOC_FREE(queue->buffer.data);			queue->buffer.size = 0;		}	}	/* It is the responsibility of the callback to free 'data' */	queue->callback(data, pkt_size, queue->private_data);	return;failed:	queue->callback(NULL, 0, queue->private_data);}
开发者ID:AIdrifter,项目名称:samba,代码行数:64,


示例27: ctdb_ltdb_store

/*  write a record to a normal database*/int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key, 		    struct ctdb_ltdb_header *header, TDB_DATA data){	struct ctdb_context *ctdb = ctdb_db->ctdb;	TDB_DATA rec;	int ret;	bool seqnum_suppressed = false;	if (ctdb_db->ctdb_ltdb_store_fn) {		return ctdb_db->ctdb_ltdb_store_fn(ctdb_db, key, header, data);	}	if (ctdb->flags & CTDB_FLAG_TORTURE) {		struct ctdb_ltdb_header *h2;		rec = tdb_fetch(ctdb_db->ltdb->tdb, key);		h2 = (struct ctdb_ltdb_header *)rec.dptr;		if (rec.dptr && rec.dsize >= sizeof(h2) && h2->rsn > header->rsn) {			DEBUG(DEBUG_CRIT,("RSN regression! %llu %llu/n",				 (unsigned long long)h2->rsn, (unsigned long long)header->rsn));		}		if (rec.dptr) free(rec.dptr);	}	rec.dsize = sizeof(*header) + data.dsize;	rec.dptr = talloc_size(ctdb, rec.dsize);	CTDB_NO_MEMORY(ctdb, rec.dptr);	memcpy(rec.dptr, header, sizeof(*header));	memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize);	/* Databases with seqnum updates enabled only get their seqnum	   changes when/if we modify the data */	if (ctdb_db->seqnum_update != NULL) {		TDB_DATA old;		old = tdb_fetch(ctdb_db->ltdb->tdb, key);		if ( (old.dsize == rec.dsize)		&& !memcmp(old.dptr+sizeof(struct ctdb_ltdb_header),			  rec.dptr+sizeof(struct ctdb_ltdb_header),			  rec.dsize-sizeof(struct ctdb_ltdb_header)) ) {			tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);			seqnum_suppressed = true;		}		if (old.dptr) free(old.dptr);	}	ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);	if (ret != 0) {		DEBUG(DEBUG_ERR, (__location__ " Failed to store dynamic data/n"));	}	if (seqnum_suppressed) {		tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);	}	talloc_free(rec.dptr);	return ret;}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:60,


示例28: test_echodata

/*  test the EchoData interface*/static bool test_echodata(struct torture_context *tctx,						  struct dcerpc_pipe *p){	int i;	NTSTATUS status;	uint8_t *data_in, *data_out;	int len;	struct echo_EchoData r;	if (torture_setting_bool(tctx, "quick", false) &&	    (p->conn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) {		len = 1 + (random() % 500);	} else {		len = 1 + (random() % 5000);	}	data_in = talloc_size(tctx, len);	data_out = talloc_size(tctx, len);	for (i=0;i<len;i++) {		data_in[i] = i;	}		r.in.len = len;	r.in.in_data = data_in;	status = dcerpc_echo_EchoData(p, tctx, &r);	torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, 											"EchoData(%d) failed/n", len));	data_out = r.out.out_data;	for (i=0;i<len;i++) {		if (data_in[i] != data_out[i]) {			torture_comment(tctx, "Bad data returned for len %d at offset %d/n", 			       len, i);			torture_comment(tctx, "in:/n");			dump_data(0, data_in+i, MIN(len-i, 16));			torture_comment(tctx, "out:/n");			dump_data(0, data_out+i, MIN(len-1, 16));			return false;		}	}	return true;}
开发者ID:technosaurus,项目名称:samba4-GPL2,代码行数:47,



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


C++ talloc_stackframe函数代码示例
C++ talloc_set_destructor函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。