这篇教程C++ talloc_memdup函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中talloc_memdup函数的典型用法代码示例。如果您正苦于以下问题:C++ talloc_memdup函数的具体用法?C++ talloc_memdup怎么用?C++ talloc_memdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了talloc_memdup函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ntlmssp_set_password/** * Converts a password to the hashes on an NTLMSSP context. * */NTSTATUS ntlmssp_set_password(struct ntlmssp_state *ntlmssp_state, const char *password){ uint8_t lm_hash[16]; uint8_t nt_hash[16]; TALLOC_FREE(ntlmssp_state->lm_hash); TALLOC_FREE(ntlmssp_state->nt_hash); if (password == NULL) { return NT_STATUS_OK; } if (E_deshash(password, lm_hash)) { ntlmssp_state->lm_hash = (uint8_t *) talloc_memdup(ntlmssp_state, lm_hash, 16); if (!ntlmssp_state->lm_hash) { return NT_STATUS_NO_MEMORY; } } E_md4hash(password, nt_hash); ntlmssp_state->nt_hash = (uint8_t *) talloc_memdup(ntlmssp_state, nt_hash, 16); if (!ntlmssp_state->nt_hash) { TALLOC_FREE(ntlmssp_state->lm_hash); return NT_STATUS_NO_MEMORY; } return NT_STATUS_OK;}
开发者ID:javierag,项目名称:samba,代码行数:35,
示例2: openchangedb_table_set_sort_order/** /details Set sort order to specified openchangedb table object /param table_object pointer to the table object /param lpSortCriteria pointer to the sort order to save /return MAPI_E_SUCCESS on success, otherwise MAPI error */_PUBLIC_ enum MAPISTATUS openchangedb_table_set_sort_order(void *table_object, struct SSortOrderSet *lpSortCriteria){ struct openchangedb_table *table; /* Sanity checks */ MAPI_RETVAL_IF(!table_object, MAPI_E_NOT_INITIALIZED, NULL); MAPI_RETVAL_IF(!lpSortCriteria, MAPI_E_INVALID_PARAMETER, NULL); table = (struct openchangedb_table *) table_object; if (table->res) { talloc_free(table->res); table->res = NULL; } if (table->lpSortCriteria) { talloc_free(table->lpSortCriteria); } if (lpSortCriteria) { table->lpSortCriteria = talloc_memdup((TALLOC_CTX *)table, lpSortCriteria, sizeof(struct SSortOrderSet)); if (!table->lpSortCriteria) { return MAPI_E_NOT_ENOUGH_MEMORY; } table->lpSortCriteria->aSort = talloc_memdup((TALLOC_CTX *)table->lpSortCriteria, lpSortCriteria->aSort, lpSortCriteria->cSorts * sizeof(struct SSortOrder)); if (!table->lpSortCriteria->aSort) { return MAPI_E_NOT_ENOUGH_MEMORY; } } else { table->lpSortCriteria = NULL; } return MAPI_E_SUCCESS;}
开发者ID:EasyLinux,项目名称:Openchange,代码行数:43,
示例3: talloc_memdup/* setup a copy of a request, used when the server needs to send more than one reply for a single request packet*/struct smbsrv_request *smbsrv_setup_secondary_request(struct smbsrv_request *old_req){ struct smbsrv_request *req; ptrdiff_t diff; req = talloc_memdup(old_req, old_req, sizeof(struct smbsrv_request)); if (req == NULL) { return NULL; } req->out.buffer = talloc_memdup(req, req->out.buffer, req->out.allocated); if (req->out.buffer == NULL) { talloc_free(req); return NULL; } diff = req->out.buffer - old_req->out.buffer; req->out.hdr += diff; req->out.vwv += diff; req->out.data += diff; req->out.ptr += diff; return req;}
开发者ID:AIdrifter,项目名称:samba,代码行数:29,
示例4: dns_copy_tsigstatic WERROR dns_copy_tsig(TALLOC_CTX *mem_ctx, struct dns_res_rec *old, struct dns_res_rec *new_rec){ new_rec->name = talloc_strdup(mem_ctx, old->name); W_ERROR_HAVE_NO_MEMORY(new_rec->name); new_rec->rr_type = old->rr_type; new_rec->rr_class = old->rr_class; new_rec->ttl = old->ttl; new_rec->length = old->length; new_rec->rdata.tsig_record.algorithm_name = talloc_strdup(mem_ctx, old->rdata.tsig_record.algorithm_name); W_ERROR_HAVE_NO_MEMORY(new_rec->rdata.tsig_record.algorithm_name); new_rec->rdata.tsig_record.time_prefix = old->rdata.tsig_record.time_prefix; new_rec->rdata.tsig_record.time = old->rdata.tsig_record.time; new_rec->rdata.tsig_record.fudge = old->rdata.tsig_record.fudge; new_rec->rdata.tsig_record.mac_size = old->rdata.tsig_record.mac_size; new_rec->rdata.tsig_record.mac = talloc_memdup(mem_ctx, old->rdata.tsig_record.mac, old->rdata.tsig_record.mac_size); W_ERROR_HAVE_NO_MEMORY(new_rec->rdata.tsig_record.mac); new_rec->rdata.tsig_record.original_id = old->rdata.tsig_record.original_id; new_rec->rdata.tsig_record.error = old->rdata.tsig_record.error; new_rec->rdata.tsig_record.other_size = old->rdata.tsig_record.other_size; new_rec->rdata.tsig_record.other_data = talloc_memdup(mem_ctx, old->rdata.tsig_record.other_data, old->rdata.tsig_record.other_size); W_ERROR_HAVE_NO_MEMORY(new_rec->rdata.tsig_record.other_data); return WERR_OK;}
开发者ID:encukou,项目名称:samba,代码行数:34,
示例5: fetch_lock_once/* Just try locking/unlocking a single record once*/static void fetch_lock_once(struct ctdb_context *ctdb, struct event_context *ev, uint32_t generation){ TALLOC_CTX *tmp_ctx = talloc_new(ctdb); TDB_DATA key, data; struct ctdb_record_handle *h; struct ctdb_ltdb_header *header; int ret; key.dptr = discard_const(TESTKEY); key.dsize = strlen(TESTKEY); printf("Trying to fetch lock the record .../n"); h = ctdb_fetch_readonly_lock(ctdb_db, tmp_ctx, key, &data, false); if (h == NULL) { printf("Failed to fetch record '%s' on node %d/n", (const char *)key.dptr, ctdb_get_pnn(ctdb)); talloc_free(tmp_ctx); exit(10); } printf("Record fetchlocked./n"); header = talloc_memdup(tmp_ctx, ctdb_header_from_record_handle(h), sizeof(*header)); printf("RSN:%d/n", (int)header->rsn); talloc_free(h); printf("Record released./n"); printf("Write new record with RSN+10/n"); header->rsn += 10; data.dptr = (void *)talloc_asprintf(tmp_ctx, "%d", (int)header->rsn); data.dsize = strlen((char *)data.dptr); ret = ctdb_ctrl_updaterecord(ctdb, ctdb, timeval_zero(), CTDB_CURRENT_NODE, ctdb_db, key, header, data); if (ret != 0) { printf("Failed to writerecord, ret==%d/n", ret); exit(1); } printf("re-fetch the record/n"); h = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, &data); if (h == NULL) { printf("Failed to fetch record '%s' on node %d/n", (const char *)key.dptr, ctdb_get_pnn(ctdb)); talloc_free(tmp_ctx); exit(10); } printf("Record fetchlocked./n"); header = talloc_memdup(tmp_ctx, ctdb_header_from_record_handle(h), sizeof(*header)); printf("RSN:%d/n", (int)header->rsn); talloc_free(h); printf("Record released./n"); talloc_free(tmp_ctx);}
开发者ID:AIdrifter,项目名称:samba,代码行数:58,
示例6: VERIFY/** Copy a single valuepair * * Allocate a new valuepair and copy the da from the old vp. * * @param[in] ctx for talloc * @param[in] vp to copy. * @return a copy of the input VP or NULL on error. */VALUE_PAIR *paircopyvp(TALLOC_CTX *ctx, VALUE_PAIR const *vp){ VALUE_PAIR *n; if (!vp) return NULL; VERIFY(vp); n = pairalloc(ctx, vp->da); if (!n) { fr_strerror_printf("out of memory"); return NULL; } memcpy(n, vp, sizeof(*n)); /* * Now copy the value */ if (vp->type == VT_XLAT) { n->value.xlat = talloc_strdup(n, n->value.xlat); } n->da = dict_attr_copy(vp->da, true); if (!n->da) { pairbasicfree(n); return NULL; } n->next = NULL; if ((n->da->type == PW_TYPE_TLV) || (n->da->type == PW_TYPE_OCTETS)) { if (n->vp_octets != NULL) { n->vp_octets = talloc_memdup(n, vp->vp_octets, n->length); } } else if (n->da->type == PW_TYPE_STRING) { if (n->vp_strvalue != NULL) { /* * Equivalent to, and faster than strdup. */ n->vp_strvalue = talloc_memdup(n, vp->vp_octets, n->length + 1); } } return n;}
开发者ID:wonlinwo,项目名称:freeradius-server,代码行数:56,
示例7: NetRemoteTOD_rWERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx, struct NetRemoteTOD *r){ NTSTATUS status; WERROR werr; struct srvsvc_NetRemoteTODInfo *info = NULL; struct dcerpc_binding_handle *b; werr = libnetapi_get_binding_handle(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, &b); if (!W_ERROR_IS_OK(werr)) { goto done; } status = dcerpc_srvsvc_NetRemoteTOD(b, talloc_tos(), r->in.server_name, &info, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } if (!W_ERROR_IS_OK(werr)) { goto done; } *r->out.buffer = (uint8_t *)talloc_memdup(ctx, info, sizeof(struct srvsvc_NetRemoteTODInfo)); W_ERROR_HAVE_NO_MEMORY(*r->out.buffer); done: return werr;}
开发者ID:nikatshun,项目名称:asuswrt-merlin,代码行数:35,
示例8: talloc_zero/* Copy a socket_address structure */struct socket_address *socket_address_copy(TALLOC_CTX *mem_ctx, const struct socket_address *oaddr){ struct socket_address *addr = talloc_zero(mem_ctx, struct socket_address); if (!addr) { return NULL; } addr->family = oaddr->family; if (oaddr->addr) { addr->addr = talloc_strdup(addr, oaddr->addr); if (!addr->addr) { goto nomem; } } addr->port = oaddr->port; if (oaddr->sockaddr) { addr->sockaddr = (struct sockaddr *)talloc_memdup(addr, oaddr->sockaddr, oaddr->sockaddrlen); if (!addr->sockaddr) { goto nomem; } addr->sockaddrlen = oaddr->sockaddrlen; } return addr;nomem: talloc_free(addr); return NULL;}
开发者ID:AIdrifter,项目名称:samba,代码行数:32,
示例9: tldap_add_blob_valsstatic bool tldap_add_blob_vals(TALLOC_CTX *mem_ctx, struct tldap_mod *mod, DATA_BLOB *newvals, int num_newvals){ int num_values = talloc_array_length(mod->values); int i; DATA_BLOB *tmp; tmp = talloc_realloc(mem_ctx, mod->values, DATA_BLOB, num_values + num_newvals); if (tmp == NULL) { return false; } mod->values = tmp; for (i=0; i<num_newvals; i++) { mod->values[i+num_values].data = (uint8_t *)talloc_memdup( mod->values, newvals[i].data, newvals[i].length); if (mod->values[i+num_values].data == NULL) { return false; } mod->values[i+num_values].length = newvals[i].length; } mod->num_values = num_values + num_newvals; return true;}
开发者ID:Arkhont,项目名称:samba,代码行数:25,
示例10: NetRemoteTOD_rWERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx, struct NetRemoteTOD *r){ struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; struct srvsvc_NetRemoteTODInfo *info = NULL; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } status = rpccli_srvsvc_NetRemoteTOD(pipe_cli, talloc_tos(), r->in.server_name, &info, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } *r->out.buffer = (uint8_t *)talloc_memdup(ctx, info, sizeof(struct srvsvc_NetRemoteTODInfo)); W_ERROR_HAVE_NO_MEMORY(*r->out.buffer); done: return werr;}
开发者ID:AllardJ,项目名称:Tomato,代码行数:31,
示例11: copy_netr_SamBaseInfoNTSTATUS copy_netr_SamBaseInfo(TALLOC_CTX *mem_ctx, const struct netr_SamBaseInfo *in, struct netr_SamBaseInfo *out){ /* first copy all, then realloc pointers */ *out = *in; COPY_LSA_STRING(mem_ctx, in, out, account_name); COPY_LSA_STRING(mem_ctx, in, out, full_name); COPY_LSA_STRING(mem_ctx, in, out, logon_script); COPY_LSA_STRING(mem_ctx, in, out, profile_path); COPY_LSA_STRING(mem_ctx, in, out, home_directory); COPY_LSA_STRING(mem_ctx, in, out, home_drive); if (in->groups.count) { out->groups.rids = (struct samr_RidWithAttribute *) talloc_memdup(mem_ctx, in->groups.rids, (sizeof(struct samr_RidWithAttribute) * in->groups.count)); NT_STATUS_HAVE_NO_MEMORY(out->groups.rids); } COPY_LSA_STRING(mem_ctx, in, out, logon_server); COPY_LSA_STRING(mem_ctx, in, out, logon_domain); if (in->domain_sid) { out->domain_sid = dom_sid_dup(mem_ctx, in->domain_sid); NT_STATUS_HAVE_NO_MEMORY(out->domain_sid); } return NT_STATUS_OK;}
开发者ID:AIdrifter,项目名称:samba,代码行数:32,
示例12: talloc_zerostruct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken){ struct security_token *token; if (!ptoken) return NULL; token = talloc_zero(mem_ctx, struct security_token); if (token == NULL) { DEBUG(0, ("talloc failed/n")); return NULL; } if (ptoken->sids && ptoken->num_sids) { token->sids = (struct dom_sid *)talloc_memdup( token, ptoken->sids, sizeof(struct dom_sid) * ptoken->num_sids ); if (token->sids == NULL) { DEBUG(0, ("talloc_memdup failed/n")); TALLOC_FREE(token); return NULL; } token->num_sids = ptoken->num_sids; } token->privilege_mask = ptoken->privilege_mask; token->rights_mask = ptoken->rights_mask; return token;}
开发者ID:AIdrifter,项目名称:samba,代码行数:30,
示例13: mapistore_push_notification_PUBLIC_ void mapistore_push_notification(struct mapistore_context *mstore_ctx, uint8_t object_type, enum mapistore_notification_type event, void *parameters){ struct mapistore_notification *new_notification; struct mapistore_notification_list *new_list; struct mapistore_table_notification_parameters *table_parameters; struct mapistore_object_notification_parameters *object_parameters; if (!mstore_ctx) return; new_list = talloc_zero(mstore_ctx, struct mapistore_notification_list); new_notification = talloc_zero(new_list, struct mapistore_notification); new_list->notification = new_notification; new_notification->object_type = object_type; new_notification->event = event; if (object_type == MAPISTORE_TABLE) { table_parameters = parameters; new_notification->parameters.table_parameters = *table_parameters; } else { object_parameters = parameters; new_notification->parameters.object_parameters = *object_parameters; if (new_notification->parameters.object_parameters.tag_count > 0 && new_notification->parameters.object_parameters.tag_count != 0xffff) { new_notification->parameters.object_parameters.tags = talloc_memdup(new_notification, new_notification->parameters.object_parameters.tags, sizeof(enum MAPITAGS) * new_notification->parameters.object_parameters.tag_count); } } DLIST_ADD_END(mstore_ctx->notifications, new_list, void);}
开发者ID:inverse-inc,项目名称:openchange.old,代码行数:30,
示例14: talloc_zerostruct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name, char *extradata, int extradata_len){ struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv); priv->log = log; priv->cur_list = talloc_array(priv, char*, 0); priv->codec = talloc_strdup(priv, codec_name); AVCodecContext *avctx = NULL; const char *fmt = get_lavc_format(priv->codec); AVCodec *codec = avcodec_find_decoder(mp_codec_to_av_codec_id(fmt)); if (!codec) goto error; avctx = avcodec_alloc_context3(codec); if (!avctx) goto error; avctx->extradata_size = extradata_len; avctx->extradata = talloc_memdup(priv, extradata, extradata_len); if (avcodec_open2(avctx, codec, NULL) < 0) goto error; // Documented as "set by libavcodec", but there is no other way avctx->time_base = (AVRational) {1, 1000}; priv->avctx = avctx; priv->extradata = talloc_strndup(priv, avctx->subtitle_header, avctx->subtitle_header_size); disable_styles(bstr0(priv->extradata)); return priv; error: MP_FATAL(priv, "Could not open libavcodec subtitle converter/n"); av_free(avctx); talloc_free(priv); return NULL;}
开发者ID:ThreeGe,项目名称:mpv,代码行数:33,
示例15: nspr_nss_initunsigned char *sss_base64_decode(TALLOC_CTX *mem_ctx, const char *inbuf, size_t *outbufsize){ int ret; unsigned char *b64decoded = NULL; unsigned int size; unsigned char *outbuf; /* initialize NSS if needed */ ret = nspr_nss_init(); if (ret != EOK) { return NULL; } b64decoded = ATOB_AsciiToData(inbuf, &size); if (!b64decoded) return NULL; outbuf = talloc_memdup(mem_ctx, b64decoded, size); PORT_Free(b64decoded); if (!outbuf) return NULL; *outbufsize = size; return outbuf;}
开发者ID:AbhishekKumarSingh,项目名称:sssd,代码行数:25,
示例16: talloc_memdup/** strdup with a talloc */char *talloc_strdup(TALLOC_CTX *t, const char *p){ if (p) return talloc_memdup(t, p, strlen(p) + 1); else return NULL;}
开发者ID:jophxy,项目名称:samba,代码行数:8,
示例17: ctdb_ibw_queue_pktstatic int ctdb_ibw_queue_pkt(struct ctdb_node *node, uint8_t *data, uint32_t length){ struct ctdb_ibw_node *cn = talloc_get_type(node->private_data, struct ctdb_ibw_node); int rc; assert(length>=sizeof(uint32_t)); assert(cn!=NULL); if (cn->conn==NULL) { DEBUG(DEBUG_ERR, ("ctdb_ibw_queue_pkt: conn is NULL/n")); return -1; } if (cn->conn->state==IBWC_CONNECTED) { rc = ctdb_ibw_send_pkt(cn->conn, data, length); } else { struct ctdb_ibw_msg *p = talloc_zero(cn, struct ctdb_ibw_msg); CTDB_NO_MEMORY(node->ctdb, p); p->data = talloc_memdup(p, data, length); CTDB_NO_MEMORY(node->ctdb, p->data); p->length = length; DLIST_ADD_AFTER(cn->queue, p, cn->queue_last); cn->queue_last = p; cn->qcnt++; rc = 0; } return rc;}
开发者ID:aoa141,项目名称:samba,代码行数:33,
示例18: recv_data/* * Handle the curl response data. We could probably simplify our chunks by * having the header on each chunk be the list as well. Oh well. */static size_t recv_data(void *data, size_t size, size_t nmemb, void *info){ struct chunk_list_struct *chunk = NULL; struct s3_request_struct *req = (struct s3_request_struct *)info; DEBUG(10, ("Received size = %zu nmemb = %zu/n", size, nmemb)); dump_data(10, data, size * nmemb); chunk = talloc_zero(req->response, struct chunk_list_struct); if (!chunk) { DEBUG(1, ("Unable to allocate space for chunk: %s, size: %zu, " " nmemb = %zu/n", strerror(errno), size, nmemb)); goto out; } chunk->chunk_size = size * nmemb; chunk->chunk = talloc_memdup(chunk, data, size * nmemb); DLIST_ADD_END(req->response->chunks, chunk, struct chunk_list_struct *);out: return nmemb * size;}
开发者ID:RichardSharpe,项目名称:Amazon-S3-VFS,代码行数:29,
示例19: talloc_PUBLIC_ struct socket_address *socket_address_from_sockaddr(TALLOC_CTX *mem_ctx, struct sockaddr *sockaddr, size_t sockaddrlen){ struct socket_address *addr = talloc(mem_ctx, struct socket_address); if (!addr) { return NULL; } switch (sockaddr->sa_family) { case AF_INET: addr->family = "ipv4"; break;#ifdef HAVE_IPV6 case AF_INET6: addr->family = "ipv6"; break;#endif case AF_UNIX: addr->family = "unix"; break; } addr->addr = NULL; addr->port = 0; addr->sockaddr = (struct sockaddr *)talloc_memdup(addr, sockaddr, sockaddrlen); if (!addr->sockaddr) { talloc_free(addr); return NULL; } addr->sockaddrlen = sockaddrlen; return addr;}
开发者ID:AIdrifter,项目名称:samba,代码行数:31,
示例20: ctdb_ltdb_fetch_with_header/* fetch a record from the ltdb, separating out the header information and returning the body of the record. if the record does not exist, *header will be NULL and data = {0, NULL}*/int ctdb_ltdb_fetch_with_header(struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data){ TDB_DATA rec; rec = tdb_fetch(ctdb_db->ltdb->tdb, key); if (rec.dsize < sizeof(*header)) { free(rec.dptr); data->dsize = 0; data->dptr = NULL; return -1; } *header = *(struct ctdb_ltdb_header *)rec.dptr; if (data) { data->dsize = rec.dsize - sizeof(struct ctdb_ltdb_header); data->dptr = talloc_memdup(mem_ctx, sizeof(struct ctdb_ltdb_header)+rec.dptr, data->dsize); } free(rec.dptr); return 0;}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:33,
示例21: TALLOC_ZERO_PNT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken){ NT_USER_TOKEN *token; if (!ptoken) return NULL; token = TALLOC_ZERO_P(mem_ctx, NT_USER_TOKEN); if (token == NULL) { DEBUG(0, ("talloc failed/n")); return NULL; } if (ptoken->user_sids && ptoken->num_sids) { token->user_sids = (DOM_SID *)talloc_memdup( token, ptoken->user_sids, sizeof(DOM_SID) * ptoken->num_sids ); if (token->user_sids == NULL) { DEBUG(0, ("talloc_memdup failed/n")); TALLOC_FREE(token); return NULL; } token->num_sids = ptoken->num_sids; } /* copy the privileges; don't consider failure to be critical here */ if ( !se_priv_copy( &token->privileges, &ptoken->privileges ) ) { DEBUG(0,("dup_nt_token: Failure to copy SE_PRIV!. " "Continuing with 0 privileges assigned./n")); } return token;}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:34,
示例22: dom_sid_string_buf/* convert a dom_sid to a string*/char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid){ char buf[DOM_SID_STR_BUFLEN]; char *result; int len; len = dom_sid_string_buf(sid, buf, sizeof(buf)); if (len+1 > sizeof(buf)) { return talloc_strdup(mem_ctx, "(SID ERR)"); } /* * Avoid calling strlen (via talloc_strdup), we already have * the length */ result = (char *)talloc_memdup(mem_ctx, buf, len+1); if (result == NULL) { return NULL; } /* * beautify the talloc_report output */ talloc_set_name_const(result, result); return result;}
开发者ID:samba-team,项目名称:samba,代码行数:30,
示例23: evlog_tdb_entry_to_evt_entryNTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx, const struct eventlog_Record_tdb *t, struct EVENTLOGRECORD *e){ uint32_t i; ZERO_STRUCTP(e); e->Length = t->size; e->Reserved = t->reserved; e->RecordNumber = t->record_number; e->TimeGenerated = t->time_generated; e->TimeWritten = t->time_written; e->EventID = t->event_id; e->EventType = t->event_type; e->NumStrings = t->num_of_strings; e->EventCategory = t->event_category; e->ReservedFlags = t->reserved_flags; e->ClosingRecordNumber = t->closing_record_number; e->StringOffset = t->stringoffset; e->UserSidLength = t->sid_length; e->UserSidOffset = t->sid_offset; e->DataLength = t->data_length; e->DataOffset = t->data_offset; e->SourceName = talloc_strdup(mem_ctx, t->source_name); NT_STATUS_HAVE_NO_MEMORY(e->SourceName); e->Computername = talloc_strdup(mem_ctx, t->computer_name); NT_STATUS_HAVE_NO_MEMORY(e->Computername); if (t->sid_length > 0) { const char *sid_str = NULL; size_t len; if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, t->sid.data, t->sid.length, (void **)&sid_str, &len, false)) { return NT_STATUS_INVALID_SID; } if (len > 0) { e->UserSid = *string_sid_talloc(mem_ctx, sid_str); } } e->Strings = talloc_array(mem_ctx, const char *, t->num_of_strings); for (i=0; i < t->num_of_strings; i++) { e->Strings[i] = talloc_strdup(e->Strings, t->strings[i]); NT_STATUS_HAVE_NO_MEMORY(e->Strings[i]); } e->Data = (uint8_t *)talloc_memdup(mem_ctx, t->data.data, t->data_length); e->Pad = talloc_strdup(mem_ctx, ""); NT_STATUS_HAVE_NO_MEMORY(e->Pad); e->Length2 = t->size; return NT_STATUS_OK;}
开发者ID:gojdic,项目名称:samba,代码行数:59,
示例24: void/* * Lock record / db depending on type */static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, TDB_DATA key, uint32_t priority, void (*callback)(void *, bool), void *private_data, enum lock_type type, bool auto_mark){ struct lock_context *lock_ctx = NULL; struct lock_request *request; if (callback == NULL) { DEBUG(DEBUG_WARNING, ("No callback function specified, not locking/n")); return NULL; }#if 0 /* Disable this optimization to ensure first-in-first-out fair * scheduling of lock requests */ /* get a context for this key - search only the pending contexts, * current contexts might in the middle of processing callbacks */ lock_ctx = find_lock_context(ctdb->lock_pending, ctdb_db, key, priority, type);#endif /* No existing context, create one */ if (lock_ctx == NULL) { lock_ctx = talloc_zero(ctdb, struct lock_context); if (lock_ctx == NULL) { DEBUG(DEBUG_ERR, ("Failed to create a new lock context/n")); return NULL; } lock_ctx->type = type; lock_ctx->ctdb = ctdb; lock_ctx->ctdb_db = ctdb_db; lock_ctx->key.dsize = key.dsize; if (key.dsize > 0) { lock_ctx->key.dptr = talloc_memdup(lock_ctx, key.dptr, key.dsize); } else { lock_ctx->key.dptr = NULL; } lock_ctx->priority = priority; lock_ctx->auto_mark = auto_mark; lock_ctx->child = -1; lock_ctx->block_child = -1; DLIST_ADD_END(ctdb->lock_pending, lock_ctx, NULL); ctdb->lock_num_pending++; CTDB_INCREMENT_STAT(ctdb, locks.num_pending); if (ctdb_db) { CTDB_INCREMENT_DB_STAT(ctdb_db, locks.num_pending); } /* Start the timer when we activate the context */ lock_ctx->start_time = timeval_current(); }
开发者ID:AIdrifter,项目名称:samba,代码行数:62,
示例25: generate_random_keystatic int generate_random_key(TALLOC_CTX *mem_ctx, PK11SlotInfo *slot, struct crypto_mech_data *mech_props, SECItem **_key){ SECStatus sret; SECItem *randkeydata; SECItem *key = NULL; PK11SymKey *randkey; int ret; randkey = PK11_KeyGen(slot, mech_props->cipher, NULL, mech_props->keylen, NULL); if (randkey == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "Failure to generate key (err %d)/n", PR_GetError()); ret = EIO; goto done; } sret = PK11_ExtractKeyValue(randkey); if (sret != SECSuccess) { DEBUG(SSSDBG_CRIT_FAILURE, "Failure to extract key value (err %d)/n", PR_GetError()); ret = EIO; goto done; } randkeydata = PK11_GetKeyData(randkey); if (randkeydata == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "Failure to get key data (err %d)/n", PR_GetError()); ret = EIO; goto done; } /* randkeydata is valid until randkey is. Copy with talloc to * get a nice memory hierarchy symmetrical in encrypt * and decrypt case */ key = talloc_zero(mem_ctx, SECItem); if (!key) { ret = ENOMEM; goto done; } key->data = talloc_memdup(key, randkeydata->data, randkeydata->len); if (!key->data) { ret = ENOMEM; goto done; } key->len = randkeydata->len; *_key = key; ret = EOK;done: if (ret != EOK) talloc_zfree(key); PK11_FreeSymKey(randkey); return ret;}
开发者ID:jhrozek,项目名称:sssd,代码行数:59,
示例26: torture_rpc_schannel2/* test two schannel connections */bool torture_rpc_schannel2(struct torture_context *torture){ struct test_join *join_ctx; NTSTATUS status; const char *binding = torture_setting_string(torture, "binding", NULL); struct dcerpc_binding *b; struct dcerpc_pipe *p1 = NULL, *p2 = NULL; struct cli_credentials *credentials1, *credentials2; uint32_t dcerpc_flags = DCERPC_SCHANNEL | DCERPC_SIGN; join_ctx = torture_join_domain(torture, talloc_asprintf(torture, "%s2", TEST_MACHINE_NAME), ACB_WSTRUST, &credentials1); torture_assert(torture, join_ctx != NULL, "Failed to join domain with acct_flags=ACB_WSTRUST"); credentials2 = (struct cli_credentials *)talloc_memdup(torture, credentials1, sizeof(*credentials1)); credentials1->netlogon_creds = NULL; credentials2->netlogon_creds = NULL; status = dcerpc_parse_binding(torture, binding, &b); torture_assert_ntstatus_ok(torture, status, "Bad binding string"); b->flags &= ~DCERPC_AUTH_OPTIONS; b->flags |= dcerpc_flags; torture_comment(torture, "Opening first connection/n"); status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon, credentials1, torture->ev, torture->lp_ctx); torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel"); torture_comment(torture, "Opening second connection/n"); status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon, credentials2, torture->ev, torture->lp_ctx); torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel"); credentials1->netlogon_creds = NULL; credentials2->netlogon_creds = NULL; torture_comment(torture, "Testing logon on pipe1/n"); if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL)) return false; torture_comment(torture, "Testing logon on pipe2/n"); if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL)) return false; torture_comment(torture, "Again on pipe1/n"); if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL)) return false; torture_comment(torture, "Again on pipe2/n"); if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL)) return false; torture_leave_domain(torture, join_ctx); return true;}
开发者ID:sameerhussain,项目名称:samba,代码行数:60,
示例27: dbwrap_fetch_parserstatic void dbwrap_fetch_parser(TDB_DATA key, TDB_DATA data, void *private_data){ struct dbwrap_fetch_state *state = (struct dbwrap_fetch_state *)private_data; state->data.dsize = data.dsize; state->data.dptr = (uint8_t *)talloc_memdup(state->mem_ctx, data.dptr, data.dsize);}
开发者ID:srimalik,项目名称:samba,代码行数:10,
注:本文中的talloc_memdup函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ talloc_named函数代码示例 C++ talloc_init函数代码示例 |