mirror of
https://github.com/samba-team/samba.git
synced 2025-03-29 02:50:28 +03:00
s3-talloc Change TALLOC_MEMDUP() to talloc_memdup()
Using the standard macro makes it easier to move code into common, as TALLOC_MEMDUP isn't standard talloc.
This commit is contained in:
parent
5e26e94092
commit
8d4a8389bb
@ -132,7 +132,7 @@ DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host,
|
||||
}
|
||||
|
||||
ip = ((const struct sockaddr_in *)pss)->sin_addr;
|
||||
if (!(data = (uint8 *)TALLOC_MEMDUP(mem_ctx, (const void *)&ip.s_addr,
|
||||
if (!(data = (uint8 *)talloc_memdup(mem_ctx, (const void *)&ip.s_addr,
|
||||
sizeof(ip.s_addr)))) {
|
||||
return ERROR_DNS_NO_MEMORY;
|
||||
}
|
||||
|
@ -907,7 +907,7 @@ struct auth_serversupplied_info *copy_serverinfo(TALLOC_CTX *mem_ctx,
|
||||
dst->utok.gid = src->utok.gid;
|
||||
dst->utok.ngroups = src->utok.ngroups;
|
||||
if (src->utok.ngroups != 0) {
|
||||
dst->utok.groups = (gid_t *)TALLOC_MEMDUP(
|
||||
dst->utok.groups = (gid_t *)talloc_memdup(
|
||||
dst, src->utok.groups,
|
||||
sizeof(gid_t)*dst->utok.ngroups);
|
||||
} else {
|
||||
|
@ -219,7 +219,6 @@ copy an IP address from one buffer to another
|
||||
#define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count))
|
||||
|
||||
#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__)
|
||||
#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__)
|
||||
#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
|
||||
#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
|
||||
#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
|
||||
|
@ -153,7 +153,7 @@ bool ctdb_packet_handler(struct ctdb_packet_context *ctx,
|
||||
ctx->in.data = NULL;
|
||||
ctx->in.length = 0;
|
||||
} else {
|
||||
buf = (uint8_t *)TALLOC_MEMDUP(ctx, ctx->in.data, length);
|
||||
buf = (uint8_t *)talloc_memdup(ctx, ctx->in.data, length);
|
||||
if (buf == NULL) {
|
||||
*status = NT_STATUS_NO_MEMORY;
|
||||
return true;
|
||||
|
@ -1563,7 +1563,7 @@ bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
|
||||
|
||||
len = p-dir;
|
||||
|
||||
if (!(*parent = (char *)TALLOC_MEMDUP(mem_ctx, dir, len+1))) {
|
||||
if (!(*parent = (char *)talloc_memdup(mem_ctx, dir, len+1))) {
|
||||
return False;
|
||||
}
|
||||
(*parent)[len] = '\0';
|
||||
|
@ -257,7 +257,7 @@ ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt)
|
||||
* discarding elements.
|
||||
*/
|
||||
|
||||
iov_copy = (struct iovec *)TALLOC_MEMDUP(
|
||||
iov_copy = (struct iovec *)talloc_memdup(
|
||||
talloc_tos(), orig_iov, sizeof(struct iovec) * iovcnt);
|
||||
|
||||
if (iov_copy == NULL) {
|
||||
|
@ -790,7 +790,7 @@ static struct berval *dup_berval(TALLOC_CTX *ctx, const struct berval *in_val)
|
||||
if (in_val->bv_len == 0) return value;
|
||||
|
||||
value->bv_len = in_val->bv_len;
|
||||
value->bv_val = (char *)TALLOC_MEMDUP(ctx, in_val->bv_val,
|
||||
value->bv_val = (char *)talloc_memdup(ctx, in_val->bv_val,
|
||||
in_val->bv_len);
|
||||
return value;
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ static NTSTATUS parse_object(TALLOC_CTX *mem_ctx,
|
||||
entry = libnet_keytab_search(ctx, principal, 0, ENCTYPE_NULL,
|
||||
mem_ctx);
|
||||
if (entry) {
|
||||
name = (char *)TALLOC_MEMDUP(mem_ctx,
|
||||
name = (char *)talloc_memdup(mem_ctx,
|
||||
entry->password.data,
|
||||
entry->password.length);
|
||||
if (!name) {
|
||||
|
@ -117,9 +117,9 @@ NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
|
||||
const uint8_t nt_hash[16])
|
||||
{
|
||||
ntlmssp_state->lm_hash = (uint8_t *)
|
||||
TALLOC_MEMDUP(ntlmssp_state, lm_hash, 16);
|
||||
talloc_memdup(ntlmssp_state, lm_hash, 16);
|
||||
ntlmssp_state->nt_hash = (uint8_t *)
|
||||
TALLOC_MEMDUP(ntlmssp_state, nt_hash, 16);
|
||||
talloc_memdup(ntlmssp_state, nt_hash, 16);
|
||||
if (!ntlmssp_state->lm_hash || !ntlmssp_state->nt_hash) {
|
||||
TALLOC_FREE(ntlmssp_state->lm_hash);
|
||||
TALLOC_FREE(ntlmssp_state->nt_hash);
|
||||
|
@ -1521,7 +1521,7 @@ void brl_close_fnum(struct messaging_context *msg_ctx,
|
||||
|
||||
/* Copy the current lock array. */
|
||||
if (br_lck->num_locks) {
|
||||
locks_copy = (struct lock_struct *)TALLOC_MEMDUP(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct));
|
||||
locks_copy = (struct lock_struct *)talloc_memdup(br_lck, locks, br_lck->num_locks * sizeof(struct lock_struct));
|
||||
if (!locks_copy) {
|
||||
smb_panic("brl_close_fnum: talloc failed");
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
|
||||
}
|
||||
|
||||
lck->share_modes = (struct share_mode_entry *)
|
||||
TALLOC_MEMDUP(lck,
|
||||
talloc_memdup(lck,
|
||||
dbuf.dptr+sizeof(struct locking_data),
|
||||
lck->num_share_modes *
|
||||
sizeof(struct share_mode_entry));
|
||||
|
@ -254,9 +254,9 @@ static bool copy_notify2_msg( SPOOLSS_NOTIFY_MSG *to, SPOOLSS_NOTIFY_MSG *from )
|
||||
memcpy( to, from, sizeof(SPOOLSS_NOTIFY_MSG) );
|
||||
|
||||
if ( from->len ) {
|
||||
to->notify.data = (char *)TALLOC_MEMDUP(send_ctx, from->notify.data, from->len );
|
||||
to->notify.data = (char *)talloc_memdup(send_ctx, from->notify.data, from->len );
|
||||
if ( !to->notify.data ) {
|
||||
DEBUG(0,("copy_notify2_msg: TALLOC_MEMDUP() of size [%d] failed!\n", from->len ));
|
||||
DEBUG(0,("copy_notify2_msg: talloc_memdup() of size [%d] failed!\n", from->len ));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ struct regval_blob *regval_compose(TALLOC_CTX *ctx, const char *name,
|
||||
fstrcpy(regval->valuename, name);
|
||||
regval->type = type;
|
||||
if (size) {
|
||||
regval->data_p = (uint8_t *)TALLOC_MEMDUP(regval, data_p, size);
|
||||
regval->data_p = (uint8_t *)talloc_memdup(regval, data_p, size);
|
||||
if (!regval->data_p) {
|
||||
TALLOC_FREE(regval);
|
||||
return NULL;
|
||||
|
@ -1720,7 +1720,7 @@ static bool create_vk_record(REGF_FILE *file, REGF_VK_REC *vk,
|
||||
if ( vk->data_size > sizeof(uint32) ) {
|
||||
uint32 data_size = ( (vk->data_size+sizeof(uint32)) & 0xfffffff8 ) + 8;
|
||||
|
||||
vk->data = (uint8 *)TALLOC_MEMDUP( file->mem_ctx,
|
||||
vk->data = (uint8 *)talloc_memdup( file->mem_ctx,
|
||||
regval_data_p(value),
|
||||
vk->data_size );
|
||||
if (vk->data == NULL) {
|
||||
|
@ -1125,7 +1125,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
|
||||
|
||||
if ( msg->len != 0 )
|
||||
msg_grp->msgs[new_slot].notify.data = (char *)
|
||||
TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len );
|
||||
talloc_memdup( ctr->ctx, msg->notify.data, msg->len );
|
||||
|
||||
return ctr->num_groups;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
|
||||
|
||||
/* Copy the header we've written. */
|
||||
|
||||
*buffer = (char *)TALLOC_MEMDUP(mem_ctx,
|
||||
*buffer = (char *)talloc_memdup(mem_ctx,
|
||||
writeX_header,
|
||||
sizeof(writeX_header));
|
||||
|
||||
|
@ -5301,7 +5301,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
|
||||
}
|
||||
|
||||
/* Copy the lock range data. */
|
||||
lock_data = (char *)TALLOC_MEMDUP(
|
||||
lock_data = (char *)talloc_memdup(
|
||||
req, pdata, total_data);
|
||||
if (!lock_data) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
|
Loading…
x
Reference in New Issue
Block a user