diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/data_blob.c | 2 | ||||
-rw-r--r-- | source4/lib/genrand.c | 2 | ||||
-rw-r--r-- | source4/lib/registry/common/reg_util.c | 2 | ||||
-rw-r--r-- | source4/lib/registry/reg_backend_nt4.c | 2 | ||||
-rw-r--r-- | source4/lib/talloc/talloc.h | 1 | ||||
-rw-r--r-- | source4/lib/talloc/testsuite.c | 18 | ||||
-rw-r--r-- | source4/lib/util_str.c | 8 |
7 files changed, 18 insertions, 17 deletions
diff --git a/source4/lib/data_blob.c b/source4/lib/data_blob.c index 18ecc2793a..deb8f55fce 100644 --- a/source4/lib/data_blob.c +++ b/source4/lib/data_blob.c @@ -37,7 +37,7 @@ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name) if (p) { ret.data = talloc_memdup(NULL, p, length); } else { - ret.data = talloc(NULL, length); + ret.data = talloc_size(NULL, length); } if (ret.data == NULL) { ret.length = 0; diff --git a/source4/lib/genrand.c b/source4/lib/genrand.c index b4651dffe8..e11f37e0e9 100644 --- a/source4/lib/genrand.c +++ b/source4/lib/genrand.c @@ -268,7 +268,7 @@ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list size_t i; size_t list_len = strlen(list); - char *retstr = talloc(mem_ctx, len + 1); + char *retstr = talloc_array_p(mem_ctx, char, len + 1); if (!retstr) return NULL; generate_random_buffer((uint8_t *)retstr, len); diff --git a/source4/lib/registry/common/reg_util.c b/source4/lib/registry/common/reg_util.c index 3a17369144..67c62fe5c8 100644 --- a/source4/lib/registry/common/reg_util.c +++ b/source4/lib/registry/common/reg_util.c @@ -63,7 +63,7 @@ char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v) return ret; case REG_BINARY: - ret = talloc(mem_ctx, v->data_len * 3 + 2); + ret = talloc_array(mem_ctx, 3, v->data_len+1, "REG_BINARY"); asciip = ret; for (i=0; i<v->data_len; i++) { int str_rem = v->data_len * 3 - (asciip - ret); diff --git a/source4/lib/registry/reg_backend_nt4.c b/source4/lib/registry/reg_backend_nt4.c index 6c48b9bd1b..cd3be85a23 100644 --- a/source4/lib/registry/reg_backend_nt4.c +++ b/source4/lib/registry/reg_backend_nt4.c @@ -917,7 +917,7 @@ static WERROR vk_to_val(TALLOC_CTX *mem_ctx, struct registry_key *parent, VK_HDR if (dat_len&0x7FFFFFFF) { - char *dtmp = (char *)talloc(mem_ctx, dat_len&0x7FFFFFFF); + char *dtmp = talloc_size(mem_ctx, dat_len&0x7FFFFFFF); if ((dat_len&0x80000000) == 0) { /* The data is pointed to by the offset */ char *dat_ptr = LOCN(regf->base, dat_off); diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h index ee3e0be8eb..99a6b7a770 100644 --- a/source4/lib/talloc/talloc.h +++ b/source4/lib/talloc/talloc.h @@ -34,6 +34,7 @@ typedef void TALLOC_CTX; /* useful macros for creating type checked pointers */ #define talloc(ctx, size) talloc_named_const(ctx, size, __location__) +#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) #define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__) #define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) #define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index a3a448ef40..ced3217105 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -335,7 +335,7 @@ static BOOL test_misc(void) root = talloc_new(NULL); - p1 = talloc(root, 0x7fffffff); + p1 = talloc_size(root, 0x7fffffff); if (p1) { printf("failed: large talloc allowed\n"); return False; @@ -517,7 +517,7 @@ static BOOL test_realloc(void) root = talloc_new(NULL); - p1 = talloc(root, 10); + p1 = talloc_size(root, 10); CHECK_SIZE(p1, 10); p1 = talloc_realloc(NULL, p1, 20); @@ -581,7 +581,7 @@ static BOOL test_realloc_child(void) printf("TESTING REALLOC WITH CHILD\n"); - root = talloc(NULL, 0); + root = talloc_new(NULL); el1 = talloc_p(root, struct el1); el1->list = talloc_p(el1, struct el2 *); @@ -607,7 +607,7 @@ static BOOL test_steal(void) printf("TESTING STEAL\n"); - root = talloc(NULL, 0); + root = talloc_new(NULL); p1 = talloc_array_p(root, char, 10); CHECK_SIZE(p1, 10); @@ -645,7 +645,7 @@ static BOOL test_steal(void) talloc_free(root); - p1 = talloc(NULL, 3); + p1 = talloc_new(NULL); CHECK_SIZE(NULL, 3); talloc_free(p1); @@ -661,7 +661,7 @@ static BOOL test_ldb(void) printf("TESTING LDB\n"); - root = talloc(NULL, 0); + root = talloc_new(NULL); p1 = talloc_realloc_fn(root, NULL, 10); CHECK_BLOCKS(root, 2); @@ -709,7 +709,7 @@ static BOOL test_unref_reparent(void) */ static BOOL test_speed(void) { - void *ctx = talloc(NULL, 0); + void *ctx = talloc_new(NULL); unsigned count; struct timeval tv; @@ -719,9 +719,9 @@ static BOOL test_speed(void) count = 0; do { void *p1, *p2, *p3; - p1 = talloc(ctx, count); + p1 = talloc_size(ctx, count); p2 = talloc_strdup(p1, "foo bar"); - p3 = talloc(p1, 300); + p3 = talloc_size(p1, 300); talloc_free(p1); count += 3; } while (timeval_elapsed(&tv) < 5.0); diff --git a/source4/lib/util_str.c b/source4/lib/util_str.c index 82481cca26..b3ec27de74 100644 --- a/source4/lib/util_str.c +++ b/source4/lib/util_str.c @@ -669,7 +669,7 @@ char *strlower_talloc(TALLOC_CTX *ctx, const char *src) /* this takes advantage of the fact that upper/lower can't change the length of a character by more than 1 byte */ - dest = talloc(ctx, 2*(strlen(src))+1); + dest = talloc_size(ctx, 2*(strlen(src))+1); if (dest == NULL) { return NULL; } @@ -704,7 +704,7 @@ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) /* this takes advantage of the fact that upper/lower can't change the length of a character by more than 1 byte */ - dest = talloc(ctx, 2*(strlen(src))+1); + dest = talloc_size(ctx, 2*(strlen(src))+1); if (dest == NULL) { return NULL; } @@ -1030,7 +1030,7 @@ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) if (!s || !*s) { return talloc_strdup(mem_ctx, ""); } - ret = talloc(mem_ctx, strlen(s)+2); + ret = talloc_size(mem_ctx, strlen(s)+2); if (!ret) { return ret; } @@ -1133,7 +1133,7 @@ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) }; char *ret; - ret = talloc(mem_ctx, ARRAY_SIZE(attr_strs)+1); + ret = talloc_size(mem_ctx, ARRAY_SIZE(attr_strs)+1); if (!ret) { return NULL; } |