From a2f77f979d7271a9708ed06f43b00ffb10ec7f4c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 12 Jan 2005 16:00:01 +0000 Subject: r4714: move the ldb code to the new talloc interface (eg remove _p suffix) this helps standalone building of ldb renew the schema module split code into functions to improve readability and code reuse add and modify works correctly but we need a proper testsuite Simo (This used to be commit a681ae365ff1b5a2771b42ebd90336651ce1e513) --- source4/lib/ldb/common/ldb_ldif.c | 16 ++++++++-------- source4/lib/ldb/common/ldb_modules.c | 4 ++-- source4/lib/ldb/common/ldb_msg.c | 16 ++++++++-------- source4/lib/ldb/common/ldb_parse.c | 10 +++++----- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'source4/lib/ldb/common') diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index d20a2a3553..546cf461f8 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -97,7 +97,7 @@ char *ldb_base64_encode(struct ldb_context *ldb, const char *buf, int len) int bytes = (len*8 + 5)/6; char *out; - out = talloc_array_p(ldb, char, bytes+2); + out = talloc_array(ldb, char, bytes+2); if (!out) return NULL; for (i=0;i= alloc_size) { char *c2; alloc_size += 1024; - c2 = talloc_realloc_p(ldb, chunk, char, alloc_size); + c2 = talloc_realloc(ldb, chunk, char, alloc_size); if (!c2) { talloc_free(chunk); errno = ENOMEM; @@ -427,7 +427,7 @@ static int msg_add_empty(struct ldb_context *ldb, { struct ldb_message_element *el2, *el; - el2 = talloc_realloc_p(msg, msg->elements, + el2 = talloc_realloc(msg, msg->elements, struct ldb_message_element, msg->num_elements+1); if (!el2) { errno = ENOMEM; @@ -468,10 +468,10 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, value.data = NULL; - ldif = talloc_p(ldb, struct ldb_ldif); + ldif = talloc(ldb, struct ldb_ldif); if (!ldif) return NULL; - ldif->msg = talloc_p(ldif, struct ldb_message); + ldif->msg = talloc(ldif, struct ldb_message); if (ldif->msg == NULL) { talloc_free(ldif); return NULL; @@ -556,7 +556,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, flags == el->flags) { /* its a continuation */ el->values = - talloc_realloc_p(msg->elements, el->values, + talloc_realloc(msg->elements, el->values, struct ldb_val, el->num_values+1); if (!el->values) { goto failed; @@ -565,7 +565,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, el->num_values++; } else { /* its a new attribute */ - msg->elements = talloc_realloc_p(ldif, msg->elements, + msg->elements = talloc_realloc(ldif, msg->elements, struct ldb_message_element, msg->num_elements+1); if (!msg->elements) { @@ -574,7 +574,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, el = &msg->elements[msg->num_elements]; el->flags = flags; el->name = talloc_strdup(msg->elements, attr); - el->values = talloc_p(msg->elements, struct ldb_val); + el->values = talloc(msg->elements, struct ldb_val); if (!el->values || !el->name) { goto failed; } diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 033717a62b..22d1ce112e 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -69,7 +69,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) *p = '\0'; q = p + 1; pn++; - modules = talloc_realloc_p(ldb, modules, char *, pn); + modules = talloc_realloc(ldb, modules, char *, pn); if (!modules) { ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in register_modules()\n"); return -1; @@ -103,7 +103,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) for (j = 0; j < msg[0]->num_elements; j++) { for (k = 0; k < msg[0]->elements[j].num_values; k++) { pn++; - modules = talloc_realloc_p(ldb, modules, char *, pn); + modules = talloc_realloc(ldb, modules, char *, pn); if (!modules) { ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in register_modules()\n"); return -1; diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 416590f462..5ab2088744 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -41,7 +41,7 @@ */ struct ldb_message *ldb_msg_new(void *mem_ctx) { - return talloc_zero_p(mem_ctx, struct ldb_message); + return talloc_zero(mem_ctx, struct ldb_message); } /* @@ -107,7 +107,7 @@ struct ldb_val ldb_val_dup(TALLOC_CTX *mem_ctx, /* the +1 is to cope with buggy C library routines like strndup that look one byte beyond */ - v2.data = talloc_array_p(mem_ctx, char, v->length+1); + v2.data = talloc_array(mem_ctx, char, v->length+1); if (!v2.data) { v2.length = 0; return v2; @@ -126,7 +126,7 @@ int ldb_msg_add_empty(struct ldb_context *ldb, { struct ldb_message_element *els; - els = talloc_realloc_p(msg, msg->elements, + els = talloc_realloc(msg, msg->elements, struct ldb_message_element, msg->num_elements+1); if (!els) { errno = ENOMEM; @@ -185,7 +185,7 @@ int ldb_msg_add_value(struct ldb_context *ldb, return -1; } - vals = talloc_realloc_p(msg, el->values, struct ldb_val, el->num_values+1); + vals = talloc_realloc(msg, el->values, struct ldb_val, el->num_values+1); if (!vals) { errno = ENOMEM; return -1; @@ -351,7 +351,7 @@ struct ldb_message *ldb_msg_copy(struct ldb_context *ldb, struct ldb_message *msg2; int i, j; - msg2 = talloc_p(ldb, struct ldb_message); + msg2 = talloc(ldb, struct ldb_message); if (msg2 == NULL) return NULL; msg2->elements = NULL; @@ -361,7 +361,7 @@ struct ldb_message *ldb_msg_copy(struct ldb_context *ldb, msg2->dn = talloc_strdup(msg2, msg->dn); if (msg2->dn == NULL) goto failed; - msg2->elements = talloc_array_p(msg2, struct ldb_message_element, msg->num_elements); + msg2->elements = talloc_array(msg2, struct ldb_message_element, msg->num_elements); if (msg2->elements == NULL) goto failed; for (i=0;inum_elements;i++) { @@ -373,7 +373,7 @@ struct ldb_message *ldb_msg_copy(struct ldb_context *ldb, el2->values = NULL; el2->name = talloc_strdup(msg2->elements, el1->name); if (el2->name == NULL) goto failed; - el2->values = talloc_array_p(msg2->elements, struct ldb_val, el1->num_values); + el2->values = talloc_array(msg2->elements, struct ldb_val, el1->num_values); for (j=0;jnum_values;j++) { el2->values[j] = ldb_val_dup(ldb, &el1->values[j]); if (el2->values[j].data == NULL && @@ -413,7 +413,7 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, struct ldb_message_element *el1 = &msg2->elements[i-1]; struct ldb_message_element *el2 = &msg2->elements[i]; if (ldb_msg_element_compare_name(el1, el2) == 0) { - el1->values = talloc_realloc_p(msg2->elements, el1->values, struct ldb_val, + el1->values = talloc_realloc(msg2->elements, el1->values, struct ldb_val, el1->num_values + el2->num_values); if (el1->values == NULL) { return NULL; diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index 6ee6f99253..d9f7dbe524 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -138,7 +138,7 @@ static struct ldb_parse_tree *ldb_parse_simple(TALLOC_CTX *ctx, const char *s) char *eq, *val, *l; struct ldb_parse_tree *ret; - ret = talloc_p(ctx, struct ldb_parse_tree); + ret = talloc(ctx, struct ldb_parse_tree); if (!ret) { errno = ENOMEM; return NULL; @@ -188,7 +188,7 @@ static struct ldb_parse_tree *ldb_parse_filterlist(TALLOC_CTX *ctx, { struct ldb_parse_tree *ret, *next; - ret = talloc_p(ctx, struct ldb_parse_tree); + ret = talloc(ctx, struct ldb_parse_tree); if (!ret) { errno = ENOMEM; return NULL; @@ -196,7 +196,7 @@ static struct ldb_parse_tree *ldb_parse_filterlist(TALLOC_CTX *ctx, ret->operation = op; ret->u.list.num_elements = 1; - ret->u.list.elements = talloc_p(ret, struct ldb_parse_tree *); + ret->u.list.elements = talloc(ret, struct ldb_parse_tree *); if (!ret->u.list.elements) { errno = ENOMEM; talloc_free(ret); @@ -213,7 +213,7 @@ static struct ldb_parse_tree *ldb_parse_filterlist(TALLOC_CTX *ctx, while (*s && (next = ldb_parse_filter(ret->u.list.elements, &s))) { struct ldb_parse_tree **e; - e = talloc_realloc_p(ret, ret->u.list.elements, + e = talloc_realloc(ret, ret->u.list.elements, struct ldb_parse_tree *, ret->u.list.num_elements+1); if (!e) { @@ -238,7 +238,7 @@ static struct ldb_parse_tree *ldb_parse_not(TALLOC_CTX *ctx, const char *s) { struct ldb_parse_tree *ret; - ret = talloc_p(ctx, struct ldb_parse_tree); + ret = talloc(ctx, struct ldb_parse_tree); if (!ret) { errno = ENOMEM; return NULL; -- cgit