mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
r4058: added a type safe version of smb_xmalloc()
(This used to be commit 1235afa5fe3a396cd7a180cbc500834a30fbaa80)
This commit is contained in:
parent
fbb5a6a0fa
commit
2f9e170f45
@ -321,3 +321,8 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
|
||||
|
||||
#endif /* _INCLUDES_H */
|
||||
|
||||
/*
|
||||
type safe varient of smb_xmalloc()
|
||||
*/
|
||||
#define smb_xmalloc_p(type) (type *)smb_xmalloc(sizeof(type))
|
||||
|
||||
|
@ -154,7 +154,7 @@ static void print_line(struct cmd_line *cl)
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -445,7 +445,7 @@ static CMD *regedit4_get_cmd(int fd)
|
||||
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;
|
||||
@ -488,7 +488,7 @@ static CMD *regedit4_get_cmd(int fd)
|
||||
* 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);
|
||||
@ -607,7 +607,7 @@ static CMD_FILE *cmd_file_create(const char *file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmp = (CMD_FILE *)smb_xmalloc(sizeof(CMD_FILE));
|
||||
tmp = smb_xmalloc_p(CMD_FILE);
|
||||
|
||||
/*
|
||||
* Let's fill in some of the fields;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
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);
|
||||
|
@ -87,7 +87,7 @@ ADS_STRUCT *ads_init(const char *realm,
|
||||
{
|
||||
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;
|
||||
|
@ -1576,8 +1576,7 @@ static int add_a_service(const service *pservice, const char *name)
|
||||
}
|
||||
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"));
|
||||
@ -1871,7 +1870,7 @@ static void copy_service(service * pserviceDest, service * pserviceSource, BOOL
|
||||
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);
|
||||
@ -1940,7 +1939,7 @@ static void add_to_file_list(const char *fname, const char *subfname)
|
||||
}
|
||||
|
||||
if (!f) {
|
||||
f = (struct file_lists *)malloc(sizeof(file_lists[0]));
|
||||
f = malloc_p(struct file_lists);
|
||||
if (!f)
|
||||
return;
|
||||
f->next = file_lists;
|
||||
@ -2247,7 +2246,7 @@ static BOOL lp_do_parameter_parametric(int snum, const char *pszParmName, const
|
||||
}
|
||||
}
|
||||
|
||||
paramo = smb_xmalloc(sizeof(*paramo));
|
||||
paramo = smb_xmalloc_p(struct param_opt);
|
||||
paramo->key = strdup(name);
|
||||
paramo->value = strdup(pszParmValue);
|
||||
paramo->flags = flags;
|
||||
|
@ -70,7 +70,7 @@ static NTSTATUS echo_TestCall(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user