From 6e6374cb5bcffb4df8bdb0a83327fff92b61ac84 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Dec 2004 07:20:30 +0000 Subject: r4055: fixed more places to use type safe allocation macros (This used to be commit eec698254f67365f27b4b7569fa982e22472aca1) --- source4/lib/registry/common/reg_interface.c | 4 ++-- source4/lib/registry/reg_backend_nt4/reg_backend_nt4.c | 16 ++++++++-------- source4/lib/registry/tools/regshell.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source4/lib/registry') 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; -- cgit