summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/gencache.c5
-rw-r--r--source4/lib/netif/interface.c2
-rw-r--r--source4/lib/registry/common/reg_interface.c4
-rw-r--r--source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c16
-rw-r--r--source4/lib/registry/tools/regshell.c4
-rw-r--r--source4/lib/replace.c2
-rw-r--r--source4/lib/util_file.c2
-rw-r--r--source4/lib/util_getent.c12
-rw-r--r--source4/lib/wins_srv.c2
-rw-r--r--source4/lib/xfile.c2
10 files changed, 25 insertions, 26 deletions
diff --git a/source4/lib/gencache.c b/source4/lib/gencache.c
index f32db598f8..160367cfe9 100644
--- a/source4/lib/gencache.c
+++ b/source4/lib/gencache.c
@@ -253,8 +253,7 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout)
time_t t;
unsigned i;
- v = (char*)malloc(sizeof(char) *
- (databuf.dsize - TIMEOUT_LEN));
+ v = malloc_array_p(char, databuf.dsize - TIMEOUT_LEN);
SAFE_FREE(databuf.dptr);
sscanf(entry_buf, CACHE_DATA_FMT, (int*)&i, v);
@@ -338,7 +337,7 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
}
entry = strndup(databuf.dptr, databuf.dsize);
SAFE_FREE(databuf.dptr);
- valstr = (char*)malloc(sizeof(char) * (databuf.dsize - TIMEOUT_LEN));
+ valstr = malloc_array_p(char, databuf.dsize - TIMEOUT_LEN);
sscanf(entry, CACHE_DATA_FMT, (int*)(&i), valstr);
timeout = i;
diff --git a/source4/lib/netif/interface.c b/source4/lib/netif/interface.c
index 3555170123..c73a2e3d7b 100644
--- a/source4/lib/netif/interface.c
+++ b/source4/lib/netif/interface.c
@@ -83,7 +83,7 @@ static void add_interface(struct in_addr ip, struct in_addr nmask)
return;
}
- iface = (struct interface *)malloc(sizeof(*iface));
+ iface = malloc_p(struct interface);
if (!iface) return;
ZERO_STRUCTPN(iface);
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index dea8861745..f7d3af0705 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -51,7 +51,7 @@ NTSTATUS registry_register(const void *_function)
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- entry = malloc(sizeof(struct reg_init_function_entry));
+ entry = malloc_p(struct reg_init_function_entry);
entry->functions = functions;
DLIST_ADD(backends, entry);
@@ -85,7 +85,7 @@ WERROR reg_create(struct registry_context **_ret)
TALLOC_CTX *mem_ctx;
struct registry_context *ret;
mem_ctx = talloc_init("registry handle");
- ret = talloc(mem_ctx, sizeof(struct registry_context));
+ ret = talloc_p(mem_ctx, struct registry_context);
ret->mem_ctx = mem_ctx;
ZERO_STRUCTP(ret);
*_ret = ret;
diff --git a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c
index aac6e548a8..381f0c3bcf 100644
--- a/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c
+++ b/source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c
@@ -540,7 +540,7 @@ static SEC_DESC *nt_create_def_sec_desc(struct registry_hive *regf)
{
SEC_DESC *tmp;
- tmp = (SEC_DESC *)malloc(sizeof(SEC_DESC));
+ tmp = malloc_p(SEC_DESC);
tmp->revision = 1;
tmp->type = SEC_DESC_SELF_RELATIVE | SEC_DESC_DACL_PRESENT;
@@ -577,7 +577,7 @@ static KEY_SEC_DESC *nt_create_init_sec(struct registry_hive *h)
REGF *regf = h->backend_data;
KEY_SEC_DESC *tsec = NULL;
- tsec = (KEY_SEC_DESC *)malloc(sizeof(KEY_SEC_DESC));
+ tsec = malloc_p(KEY_SEC_DESC);
tsec->ref_cnt = 1;
tsec->state = SEC_DESC_NBK;
@@ -682,7 +682,7 @@ static SK_MAP *alloc_sk_map_entry(struct registry_hive *h, KEY_SEC_DESC *tmp, in
{
REGF *regf = h->backend_data;
if (!regf->sk_map) { /* Allocate a block of 10 */
- regf->sk_map = (SK_MAP *)malloc(sizeof(SK_MAP) * 10);
+ regf->sk_map = malloc_array_p(SK_MAP, 10);
regf->sk_map_size = 10;
regf->sk_count = 1;
(regf->sk_map)[0].sk_off = sk_off;
@@ -742,7 +742,7 @@ static KEY_SEC_DESC *lookup_create_sec_key(struct registry_hive *h, SK_MAP *sk_m
return tmp;
}
else { /* Allocate a new one */
- tmp = (KEY_SEC_DESC *)malloc(sizeof(KEY_SEC_DESC));
+ tmp = malloc_p(KEY_SEC_DESC);
memset(tmp, 0, sizeof(KEY_SEC_DESC)); /* Neatly sets offset to 0 */
tmp->state = SEC_DESC_RES;
if (!alloc_sk_map_entry(h, tmp, sk_off)) {
@@ -756,7 +756,7 @@ static SEC_DESC *process_sec_desc(struct registry_hive *regf, SEC_DESC *sec_desc
{
SEC_DESC *tmp = NULL;
- tmp = (SEC_DESC *)malloc(sizeof(SEC_DESC));
+ tmp = malloc_p(SEC_DESC);
tmp->revision = SVAL(&sec_desc->revision,0);
tmp->type = SVAL(&sec_desc->type,0);
@@ -838,7 +838,7 @@ static KEY_SEC_DESC *process_sk(struct registry_hive *regf, SK_HDR *sk_hdr, int
*/
if (!tmp) {
- tmp = (KEY_SEC_DESC *)malloc(sizeof(KEY_SEC_DESC));
+ tmp = malloc_p(KEY_SEC_DESC);
memset(tmp, 0, sizeof(KEY_SEC_DESC));
/*
@@ -1154,7 +1154,7 @@ static HBIN_BLK *nt_create_hbin_blk(struct registry_hive *h, int size)
size = (size + (REGF_HDR_BLKSIZ - 1)) & ~(REGF_HDR_BLKSIZ - 1);
- tmp = (HBIN_BLK *)malloc(sizeof(HBIN_BLK));
+ tmp = malloc_p(HBIN_BLK);
memset(tmp, 0, sizeof(HBIN_BLK));
tmp->data = malloc(size);
@@ -1553,7 +1553,7 @@ static REGF_HDR *nt_get_reg_header(struct registry_hive *h) {
REGF *regf = h->backend_data;
HBIN_BLK *tmp = NULL;
- tmp = (HBIN_BLK *)malloc(sizeof(HBIN_BLK));
+ tmp = malloc_p(HBIN_BLK);
memset(tmp, 0, sizeof(HBIN_BLK));
tmp->type = REG_OUTBLK_HDR;
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 3333299088..f18b012720 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -247,7 +247,7 @@ static char **reg_complete_command(const char *text, int end)
char **matches;
int i, len, samelen=0, count=1;
- matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS);
+ matches = malloc_array_p(char *, MAX_COMPLETIONS);
if (!matches) return NULL;
matches[0] = NULL;
@@ -301,7 +301,7 @@ static char **reg_complete_key(const char *text, int end)
TALLOC_CTX *mem_ctx;
/* Complete argument */
- matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS);
+ matches = malloc_array_p(char *, MAX_COMPLETIONS);
if (!matches) return NULL;
matches[0] = NULL;
diff --git a/source4/lib/replace.c b/source4/lib/replace.c
index 35e0277c59..ca367da9b5 100644
--- a/source4/lib/replace.c
+++ b/source4/lib/replace.c
@@ -205,7 +205,7 @@ Corrections by richard.kettlewell@kewill.com
struct group *g;
char *gr;
- if((grouplst = (gid_t *)malloc(sizeof(gid_t) * max_gr)) == NULL) {
+ if((grouplst = malloc_array_p(gid_t, max_gr)) == NULL) {
DEBUG(0,("initgroups: malloc fail !\n"));
return -1;
}
diff --git a/source4/lib/util_file.c b/source4/lib/util_file.c
index f9697fb337..2b2fe2b2af 100644
--- a/source4/lib/util_file.c
+++ b/source4/lib/util_file.c
@@ -281,7 +281,7 @@ static char **file_lines_parse(char *p, size_t size, int *numlines)
if (s[0] == '\n') i++;
}
- ret = (char **)malloc(sizeof(ret[0])*(i+2));
+ ret = malloc_array_p(char *, i+2);
if (!ret) {
SAFE_FREE(p);
return NULL;
diff --git a/source4/lib/util_getent.c b/source4/lib/util_getent.c
index 599e4bb917..9f58472fb8 100644
--- a/source4/lib/util_getent.c
+++ b/source4/lib/util_getent.c
@@ -33,7 +33,7 @@ struct sys_grent * getgrent_list(void)
struct sys_grent *gent;
struct group *grp;
- gent = (struct sys_grent *) malloc(sizeof(struct sys_grent));
+ gent = malloc_p(struct sys_grent);
if (gent == NULL) {
DEBUG (0, ("Out of memory in getgrent_list!\n"));
return NULL;
@@ -67,7 +67,7 @@ struct sys_grent * getgrent_list(void)
;
/* alloc space for gr_mem string pointers */
- if ((gent->gr_mem = (char **) malloc((num+1) * sizeof(char *))) == NULL)
+ if ((gent->gr_mem = malloc_array_p(char *, num+1)) == NULL)
goto err;
memset(gent->gr_mem, '\0', (num+1) * sizeof(char *));
@@ -80,7 +80,7 @@ struct sys_grent * getgrent_list(void)
grp = getgrent();
if (grp) {
- gent->next = (struct sys_grent *) malloc(sizeof(struct sys_grent));
+ gent->next = malloc_p(struct sys_grent);
if (gent->next == NULL)
goto err;
gent = gent->next;
@@ -134,7 +134,7 @@ struct sys_pwent * getpwent_list(void)
struct sys_pwent *pent;
struct passwd *pwd;
- pent = (struct sys_pwent *) malloc(sizeof(struct sys_pwent));
+ pent = malloc_p(struct sys_pwent);
if (pent == NULL) {
DEBUG (0, ("Out of memory in getpwent_list!\n"));
return NULL;
@@ -170,7 +170,7 @@ struct sys_pwent * getpwent_list(void)
pwd = getpwent();
if (pwd) {
- pent->next = (struct sys_pwent *) malloc(sizeof(struct sys_pwent));
+ pent->next = malloc_p(struct sys_pwent);
if (pent->next == NULL)
goto err;
pent = pent->next;
@@ -223,7 +223,7 @@ static struct sys_userlist *add_members_to_userlist(struct sys_userlist *list_he
;
for (i = 0; i < num_users; i++) {
- struct sys_userlist *entry = (struct sys_userlist *)malloc(sizeof(*entry));
+ struct sys_userlist *entry = malloc_p(struct sys_userlist);
if (entry == NULL) {
free_userlist(list_head);
return NULL;
diff --git a/source4/lib/wins_srv.c b/source4/lib/wins_srv.c
index 094de8d6b0..0338db8b3d 100644
--- a/source4/lib/wins_srv.c
+++ b/source4/lib/wins_srv.c
@@ -204,7 +204,7 @@ char **wins_srv_tags(void)
if (lp_wins_support()) {
/* give the caller something to chew on. This makes
the rest of the logic simpler (ie. less special cases) */
- ret = (char **)malloc(sizeof(char *)*2);
+ ret = malloc_array_p(char *, 2);
if (!ret) return NULL;
ret[0] = strdup("*");
ret[1] = NULL;
diff --git a/source4/lib/xfile.c b/source4/lib/xfile.c
index 856e5dd6e6..794e3f0f5e 100644
--- a/source4/lib/xfile.c
+++ b/source4/lib/xfile.c
@@ -96,7 +96,7 @@ XFILE *x_fopen(const char *fname, int flags, mode_t mode)
{
XFILE *ret;
- ret = (XFILE *)malloc(sizeof(XFILE));
+ ret = malloc_p(XFILE);
if (!ret) return NULL;
memset(ret, 0, sizeof(XFILE));