#endif /* _INCLUDES_H */
+/*
+ type safe varient of smb_xmalloc()
+*/
+#define smb_xmalloc_p(type) (type *)smb_xmalloc(sizeof(type))
+
*/
static struct cmd_line *get_cmd_line(int fd)
{
- struct cmd_line *cl = (CMD_LINE *)smb_xmalloc(sizeof(CMD_LINE));
+ struct cmd_line *cl = smb_xmalloc_p(CMD_LINE);
int i = 0, rc;
uint8_t ch;
struct cmd_line *cl = NULL;
struct val_spec_list *vl = NULL;
- cmd = (struct command_s *)smb_xmalloc(sizeof(struct command_s));
+ cmd = smb_xmalloc_p(struct command_s);
cmd->cmd = CMD_NONE;
cmd->key = NULL;
* There could be a \ on the end which we need to
* handle at some time
*/
- vl = (struct val_spec_list *)smb_xmalloc(sizeof(struct val_spec_list));
+ vl = smb_xmalloc_p(struct val_spec_list);
vl->next = NULL;
vl->val = NULL;
vl->name = parse_value(cl, &vl->type, &vl->val);
return NULL;
}
- tmp = (CMD_FILE *)smb_xmalloc(sizeof(CMD_FILE));
+ tmp = smb_xmalloc_p(CMD_FILE);
/*
* Let's fill in some of the fields;
static struct passwd *alloc_copy_passwd(const struct passwd *from)
{
- struct passwd *ret = smb_xmalloc(sizeof(struct passwd));
+ struct passwd *ret = smb_xmalloc_p(struct passwd);
ZERO_STRUCTP(ret);
ret->pw_name = smb_xstrdup(from->pw_name);
ret->pw_passwd = smb_xstrdup(from->pw_passwd);
{
ADS_STRUCT *ads;
- ads = (ADS_STRUCT *)smb_xmalloc(sizeof(*ads));
+ ads = smb_xmalloc_p(ADS_STRUCT);
ZERO_STRUCTP(ads);
ads->server.realm = realm? strdup(realm) : NULL;
}
else {
ServicePtrs = tsp;
- ServicePtrs[iNumServices] =
- (service *) malloc(sizeof(service));
+ ServicePtrs[iNumServices] = malloc_p(service);
}
if (!ServicePtrs[iNumServices]) {
DEBUG(0,("add_a_service: out of memory!\n"));
pdata = pdata->next;
}
if (not_added) {
- paramo = smb_xmalloc(sizeof(*paramo));
+ paramo = smb_xmalloc_p(struct param_opt);
paramo->key = strdup(data->key);
paramo->value = strdup(data->value);
DLIST_ADD(pserviceDest->param_opt, paramo);
}
if (!f) {
- f = (struct file_lists *)malloc(sizeof(file_lists[0]));
+ f = malloc_p(struct file_lists);
if (!f)
return;
f->next = file_lists;
}
}
- paramo = smb_xmalloc(sizeof(*paramo));
+ paramo = smb_xmalloc_p(struct param_opt);
paramo->key = strdup(name);
paramo->value = strdup(pszParmValue);
paramo->flags = flags;
static NTSTATUS echo_TestCall2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_TestCall2 *r)
{
- r->out.info = talloc(mem_ctx, sizeof(*r->out.info));
+ r->out.info = talloc_p(mem_ctx, union echo_Info);
if (!r->out.info) {
return NT_STATUS_NO_MEMORY;
}