SMB_CALLOC_ARRAY(..., 1) does this.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
TALLOC_CTX *frame = talloc_stackframe();
while (1) {
- t = SMB_MALLOC_P(struct chat_struct);
+ t = SMB_CALLOC_ARRAY(struct chat_struct, 1);
if (!t) {
DEBUG(0,("make_pw_chat: malloc failed!\n"));
TALLOC_FREE(frame);
return NULL;
}
- ZERO_STRUCTP(t);
-
DLIST_ADD_END(list, t);
if (!next_token_talloc(frame, &p, &prompt, NULL)) {
return;
}
- iface = SMB_MALLOC_P(struct interface);
+ iface = SMB_CALLOC_ARRAY(struct interface, 1);
if (!iface) {
return;
}
- ZERO_STRUCTPN(iface);
-
iface->name = SMB_STRDUP(ifs->name);
if (!iface->name) {
SAFE_FREE(iface);
if (ret < 0) {
return ret;
}
- rhd = SMB_MALLOC_P(struct readahead_data);
+ rhd = SMB_CALLOC_ARRAY(struct readahead_data, 1);
if (!rhd) {
SMB_VFS_NEXT_DISCONNECT(handle);
DEBUG(0,("readahead_connect: out of memory\n"));
return -1;
}
- ZERO_STRUCTP(rhd);
rhd->didmsg = False;
rhd->off_bound = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
return NULL;
}
- dirp = SMB_MALLOC_P(shadow_copy_Dir);
+ dirp = SMB_CALLOC_ARRAY(shadow_copy_Dir, 1);
if (!dirp) {
DEBUG(0,("shadow_copy_fdopendir: Out of memory\n"));
SMB_VFS_NEXT_CLOSEDIR(handle,p);
return NULL;
}
- ZERO_STRUCTP(dirp);
-
while (True) {
struct dirent *d;
if (!p) {
/* Create one. */
- p = SMB_MALLOC_P(struct tdb_print_db);
+ p = SMB_CALLOC_ARRAY(struct tdb_print_db, 1);
if (!p) {
DEBUG(0,("get_print_db: malloc fail !\n"));
return NULL;
}
- ZERO_STRUCTP(p);
DLIST_ADD(print_db_head, p);
}
{
REGF_FILE *rb;
- if ( !(rb = SMB_MALLOC_P(REGF_FILE)) ) {
+ if (!(rb = SMB_CALLOC_ARRAY(REGF_FILE, 1))) {
DEBUG(0,("ERROR allocating memory\n"));
return NULL;
}
- ZERO_STRUCTP( rb );
rb->fd = -1;
rb->ignore_checksums = false;
if (strncmp((const char *)kbuf.dptr, "CRED/", 5) == 0) {
- cred = SMB_MALLOC_P(struct cred_list);
+ cred = SMB_CALLOC_ARRAY(struct cred_list, 1);
if (cred == NULL) {
DBG_ERR("traverse_fn_remove_first_creds: failed to malloc new entry for list\n");
return -1;
}
- ZERO_STRUCTP(cred);
-
/* save a copy of the key */
fstrcpy(cred->name, (const char *)kbuf.dptr);