mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
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 a681ae365f
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
7588b41e15
commit
a2f77f979d
@ -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<bytes;i++) {
|
||||
@ -305,7 +305,7 @@ static char *next_chunk(struct ldb_context *ldb,
|
||||
if (chunk_size+1 >= 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;i<msg->num_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;j<el1->num_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;
|
||||
|
@ -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;
|
||||
|
@ -161,7 +161,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
|
||||
return -1;
|
||||
}
|
||||
|
||||
el = talloc_realloc_p(msg, msg->elements, struct ldb_message_element,
|
||||
el = talloc_realloc(msg, msg->elements, struct ldb_message_element,
|
||||
msg->num_elements + 1);
|
||||
if (!el) {
|
||||
errno = ENOMEM;
|
||||
@ -180,7 +180,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
|
||||
el->flags = 0;
|
||||
|
||||
el->num_values = 0;
|
||||
el->values = talloc_array_p(msg->elements, struct ldb_val, count);
|
||||
el->values = talloc_array(msg->elements, struct ldb_val, count);
|
||||
if (!el->values) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
@ -230,7 +230,7 @@ static int lldb_search(struct ldb_module *module, const char *base,
|
||||
return count;
|
||||
}
|
||||
|
||||
(*res) = talloc_array_p(lldb, struct ldb_message *, count+1);
|
||||
(*res) = talloc_array(lldb, struct ldb_message *, count+1);
|
||||
if (! *res) {
|
||||
ldap_msgfree(ldapres);
|
||||
errno = ENOMEM;
|
||||
@ -254,7 +254,7 @@ static int lldb_search(struct ldb_module *module, const char *base,
|
||||
break;
|
||||
}
|
||||
|
||||
(*res)[msg_count] = talloc_p(*res, struct ldb_message);
|
||||
(*res)[msg_count] = talloc(*res, struct ldb_message);
|
||||
if (!(*res)[msg_count]) {
|
||||
goto failed;
|
||||
}
|
||||
@ -317,7 +317,7 @@ static LDAPMod **lldb_msg_to_mods(struct ldb_context *ldb,
|
||||
int num_mods = 0;
|
||||
|
||||
/* allocate maximum number of elements needed */
|
||||
mods = talloc_array_p(ldb, LDAPMod *, msg->num_elements+1);
|
||||
mods = talloc_array(ldb, LDAPMod *, msg->num_elements+1);
|
||||
if (!mods) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
@ -327,7 +327,7 @@ static LDAPMod **lldb_msg_to_mods(struct ldb_context *ldb,
|
||||
for (i=0;i<msg->num_elements;i++) {
|
||||
const struct ldb_message_element *el = &msg->elements[i];
|
||||
|
||||
mods[num_mods] = talloc_p(ldb, LDAPMod);
|
||||
mods[num_mods] = talloc(ldb, LDAPMod);
|
||||
if (!mods[num_mods]) {
|
||||
goto failed;
|
||||
}
|
||||
@ -347,7 +347,7 @@ static LDAPMod **lldb_msg_to_mods(struct ldb_context *ldb,
|
||||
}
|
||||
}
|
||||
mods[num_mods]->mod_type = el->name;
|
||||
mods[num_mods]->mod_vals.modv_bvals = talloc_array_p(mods[num_mods],
|
||||
mods[num_mods]->mod_vals.modv_bvals = talloc_array(mods[num_mods],
|
||||
struct berval *,
|
||||
1+el->num_values);
|
||||
if (!mods[num_mods]->mod_vals.modv_bvals) {
|
||||
@ -355,7 +355,7 @@ static LDAPMod **lldb_msg_to_mods(struct ldb_context *ldb,
|
||||
}
|
||||
|
||||
for (j=0;j<el->num_values;j++) {
|
||||
mods[num_mods]->mod_vals.modv_bvals[j] = talloc_p(mods[num_mods]->mod_vals.modv_bvals,
|
||||
mods[num_mods]->mod_vals.modv_bvals[j] = talloc(mods[num_mods]->mod_vals.modv_bvals,
|
||||
struct berval);
|
||||
if (!mods[num_mods]->mod_vals.modv_bvals[j]) {
|
||||
goto failed;
|
||||
@ -499,13 +499,13 @@ struct ldb_context *lldb_connect(const char *url,
|
||||
struct lldb_private *lldb = NULL;
|
||||
int i, version = 3;
|
||||
|
||||
ldb = talloc_p(NULL, struct ldb_context);
|
||||
ldb = talloc(NULL, struct ldb_context);
|
||||
if (!ldb) {
|
||||
errno = ENOMEM;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
lldb = talloc_p(ldb, struct lldb_private);
|
||||
lldb = talloc(ldb, struct lldb_private);
|
||||
if (!lldb) {
|
||||
errno = ENOMEM;
|
||||
goto failed;
|
||||
@ -526,7 +526,7 @@ struct ldb_context *lldb_connect(const char *url,
|
||||
goto failed;
|
||||
}
|
||||
|
||||
ldb->modules = talloc_p(ldb, struct ldb_module);
|
||||
ldb->modules = talloc(ldb, struct ldb_module);
|
||||
if (!ldb->modules) {
|
||||
errno = ENOMEM;
|
||||
goto failed;
|
||||
@ -541,7 +541,7 @@ struct ldb_context *lldb_connect(const char *url,
|
||||
on the caller keeping it around (it might be dynamic) */
|
||||
for (i=0;options[i];i++) ;
|
||||
|
||||
lldb->options = talloc_array_p(lldb, char *, i+1);
|
||||
lldb->options = talloc_array(lldb, char *, i+1);
|
||||
if (!lldb->options) {
|
||||
goto failed;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ static int ltdb_baseinfo_init(struct ldb_module *module)
|
||||
|
||||
ltdb->sequence_number = atof(initial_sequence_number);
|
||||
|
||||
msg = talloc_p(ltdb, struct ldb_message);
|
||||
msg = talloc(ltdb, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
@ -120,11 +120,11 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
double seq;
|
||||
|
||||
if (ltdb->cache == NULL) {
|
||||
ltdb->cache = talloc_zero_p(ltdb, struct ltdb_cache);
|
||||
ltdb->cache = talloc_zero(ltdb, struct ltdb_cache);
|
||||
if (ltdb->cache == NULL) goto failed;
|
||||
ltdb->cache->indexlist = talloc_zero_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->subclasses = talloc_zero_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->attributes = talloc_zero_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->indexlist = talloc_zero(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->subclasses = talloc_zero(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->attributes = talloc_zero(ltdb->cache, struct ldb_message);
|
||||
if (ltdb->cache->indexlist == NULL ||
|
||||
ltdb->cache->subclasses == NULL ||
|
||||
ltdb->cache->attributes == NULL) {
|
||||
@ -133,7 +133,7 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
}
|
||||
|
||||
talloc_free(ltdb->cache->baseinfo);
|
||||
ltdb->cache->baseinfo = talloc_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->baseinfo = talloc(ltdb->cache, struct ldb_message);
|
||||
if (ltdb->cache->baseinfo == NULL) goto failed;
|
||||
|
||||
if (ltdb_search_dn1(module, LTDB_BASEINFO, ltdb->cache->baseinfo) == -1) {
|
||||
@ -165,9 +165,9 @@ int ltdb_cache_load(struct ldb_module *module)
|
||||
talloc_free(ltdb->cache->subclasses);
|
||||
talloc_free(ltdb->cache->attributes);
|
||||
|
||||
ltdb->cache->indexlist = talloc_zero_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->subclasses = talloc_zero_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->attributes = talloc_zero_p(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->indexlist = talloc_zero(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->subclasses = talloc_zero(ltdb->cache, struct ldb_message);
|
||||
ltdb->cache->attributes = talloc_zero(ltdb->cache, struct ldb_message);
|
||||
if (ltdb->cache->indexlist == NULL ||
|
||||
ltdb->cache->subclasses == NULL ||
|
||||
ltdb->cache->attributes == NULL) {
|
||||
@ -204,7 +204,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
|
||||
char *s = NULL;
|
||||
int ret;
|
||||
|
||||
msg = talloc_p(ltdb, struct ldb_message);
|
||||
msg = talloc(ltdb, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
|
@ -180,7 +180,7 @@ static int ltdb_index_dn_simple(struct ldb_module *module,
|
||||
dn = ldb_dn_key(ldb, tree->u.simple.attr, &tree->u.simple.value);
|
||||
if (!dn) return -1;
|
||||
|
||||
msg = talloc_p(list, struct ldb_message);
|
||||
msg = talloc(list, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -200,7 +200,7 @@ static int ltdb_index_dn_simple(struct ldb_module *module,
|
||||
|
||||
el = &msg->elements[i];
|
||||
|
||||
list->dn = talloc_array_p(list, char *, el->num_values);
|
||||
list->dn = talloc_array(list, char *, el->num_values);
|
||||
if (!list->dn) {
|
||||
break;
|
||||
}
|
||||
@ -259,7 +259,7 @@ static int ltdb_index_dn_objectclass(struct ldb_module *module,
|
||||
return -1;
|
||||
}
|
||||
tree2.u.simple.value = el->values[j];
|
||||
list2 = talloc_p(list, struct dn_list);
|
||||
list2 = talloc(list, struct dn_list);
|
||||
if (list2 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -313,12 +313,12 @@ static int list_intersect(struct ldb_context *ldb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
list3 = talloc_p(ldb, struct dn_list);
|
||||
list3 = talloc(ldb, struct dn_list);
|
||||
if (list3 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
list3->dn = talloc_array_p(list3, char *, list->count);
|
||||
list3->dn = talloc_array(list3, char *, list->count);
|
||||
if (!list3->dn) {
|
||||
talloc_free(list);
|
||||
talloc_free(list3);
|
||||
@ -363,7 +363,7 @@ static int list_union(struct ldb_context *ldb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
d = talloc_realloc_p(list, list->dn, char *, list->count + list2->count);
|
||||
d = talloc_realloc(list, list->dn, char *, list->count + list2->count);
|
||||
if (!d) {
|
||||
talloc_free(list);
|
||||
return -1;
|
||||
@ -415,7 +415,7 @@ static int ltdb_index_dn_or(struct ldb_module *module,
|
||||
struct dn_list *list2;
|
||||
int v;
|
||||
|
||||
list2 = talloc_p(module, struct dn_list);
|
||||
list2 = talloc(module, struct dn_list);
|
||||
if (list2 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -500,7 +500,7 @@ static int ltdb_index_dn_and(struct ldb_module *module,
|
||||
struct dn_list *list2;
|
||||
int v;
|
||||
|
||||
list2 = talloc_p(module, struct dn_list);
|
||||
list2 = talloc(module, struct dn_list);
|
||||
if (list2 == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -591,7 +591,7 @@ static int ldb_index_filter(struct ldb_module *module, struct ldb_parse_tree *tr
|
||||
struct ldb_message *msg;
|
||||
int ret;
|
||||
|
||||
msg = talloc_p(module, struct ldb_message);
|
||||
msg = talloc(module, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -642,7 +642,7 @@ int ltdb_search_indexed(struct ldb_module *module,
|
||||
return -1;
|
||||
}
|
||||
|
||||
dn_list = talloc_p(module, struct dn_list);
|
||||
dn_list = talloc(module, struct dn_list);
|
||||
if (dn_list == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -672,7 +672,7 @@ static int ltdb_index_add1_new(struct ldb_context *ldb,
|
||||
struct ldb_message_element *el2;
|
||||
|
||||
/* add another entry */
|
||||
el2 = talloc_realloc_p(msg, msg->elements,
|
||||
el2 = talloc_realloc(msg, msg->elements,
|
||||
struct ldb_message_element, msg->num_elements+1);
|
||||
if (!el2) {
|
||||
return -1;
|
||||
@ -684,7 +684,7 @@ static int ltdb_index_add1_new(struct ldb_context *ldb,
|
||||
return -1;
|
||||
}
|
||||
msg->elements[msg->num_elements].num_values = 0;
|
||||
msg->elements[msg->num_elements].values = talloc_p(msg->elements, struct ldb_val);
|
||||
msg->elements[msg->num_elements].values = talloc(msg->elements, struct ldb_val);
|
||||
if (!msg->elements[msg->num_elements].values) {
|
||||
return -1;
|
||||
}
|
||||
@ -717,7 +717,7 @@ static int ltdb_index_add1_add(struct ldb_context *ldb,
|
||||
}
|
||||
}
|
||||
|
||||
v2 = talloc_realloc_p(msg->elements, msg->elements[idx].values,
|
||||
v2 = talloc_realloc(msg->elements, msg->elements[idx].values,
|
||||
struct ldb_val,
|
||||
msg->elements[idx].num_values+1);
|
||||
if (!v2) {
|
||||
@ -749,7 +749,7 @@ static int ltdb_index_add1(struct ldb_module *module, char *dn,
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = talloc_p(dn_key, struct ldb_message);
|
||||
msg = talloc(dn_key, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -842,7 +842,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = talloc_p(dn_key, struct ldb_message);
|
||||
msg = talloc(dn_key, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
talloc_free(dn_key);
|
||||
return -1;
|
||||
@ -948,7 +948,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
|
||||
return 0;
|
||||
}
|
||||
|
||||
msg = talloc_p(module, struct ldb_message);
|
||||
msg = talloc(module, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ int ltdb_pack_data(struct ldb_module *module,
|
||||
}
|
||||
|
||||
/* allocate it */
|
||||
data->dptr = talloc_array_p(ldb, char, size);
|
||||
data->dptr = talloc_array(ldb, char, size);
|
||||
if (!data->dptr) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
@ -199,7 +199,7 @@ int ltdb_unpack_data(struct ldb_module *module,
|
||||
goto failed;
|
||||
}
|
||||
|
||||
message->elements = talloc_array_p(message, struct ldb_message_element, message->num_elements);
|
||||
message->elements = talloc_array(message, struct ldb_message_element, message->num_elements);
|
||||
if (!message->elements) {
|
||||
errno = ENOMEM;
|
||||
goto failed;
|
||||
@ -225,7 +225,7 @@ int ltdb_unpack_data(struct ldb_module *module,
|
||||
message->elements[i].num_values = pull_uint32(p, 0);
|
||||
message->elements[i].values = NULL;
|
||||
if (message->elements[i].num_values != 0) {
|
||||
message->elements[i].values = talloc_array_p(message->elements,
|
||||
message->elements[i].values = talloc_array(message->elements,
|
||||
struct ldb_val,
|
||||
message->elements[i].num_values);
|
||||
if (!message->elements[i].values) {
|
||||
|
@ -47,7 +47,7 @@ static int msg_add_element(struct ldb_context *ldb,
|
||||
unsigned int i;
|
||||
struct ldb_message_element *e2, *elnew;
|
||||
|
||||
e2 = talloc_realloc_p(ret, ret->elements, struct ldb_message_element, ret->num_elements+1);
|
||||
e2 = talloc_realloc(ret, ret->elements, struct ldb_message_element, ret->num_elements+1);
|
||||
if (!e2) {
|
||||
return -1;
|
||||
}
|
||||
@ -61,7 +61,7 @@ static int msg_add_element(struct ldb_context *ldb,
|
||||
}
|
||||
|
||||
if (el->num_values) {
|
||||
elnew->values = talloc_array_p(ret->elements, struct ldb_val, el->num_values);
|
||||
elnew->values = talloc_array(ret->elements, struct ldb_val, el->num_values);
|
||||
if (!elnew->values) {
|
||||
return -1;
|
||||
}
|
||||
@ -117,7 +117,7 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
|
||||
struct ldb_message *ret;
|
||||
int i;
|
||||
|
||||
ret = talloc_p(ldb, struct ldb_message);
|
||||
ret = talloc(ldb, struct ldb_message);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
@ -279,12 +279,12 @@ int ltdb_search_dn(struct ldb_module *module, char *dn,
|
||||
int ret;
|
||||
struct ldb_message *msg, *msg2;
|
||||
|
||||
*res = talloc_array_p(ldb, struct ldb_message *, 2);
|
||||
*res = talloc_array(ldb, struct ldb_message *, 2);
|
||||
if (! *res) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = talloc_p(*res, struct ldb_message);
|
||||
msg = talloc(*res, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
talloc_free(*res);
|
||||
*res = NULL;
|
||||
@ -333,7 +333,7 @@ int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg,
|
||||
}
|
||||
|
||||
/* add to the results list */
|
||||
res2 = talloc_realloc_p(ldb, *res, struct ldb_message *, (*count)+2);
|
||||
res2 = talloc_realloc(ldb, *res, struct ldb_message *, (*count)+2);
|
||||
if (!res2) {
|
||||
talloc_free(msg2);
|
||||
return -1;
|
||||
@ -378,7 +378,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
|
||||
return 0;
|
||||
}
|
||||
|
||||
msg = talloc_p(sinfo, struct ldb_message);
|
||||
msg = talloc(sinfo, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@ -442,7 +442,7 @@ static int ltdb_search_full(struct ldb_module *module,
|
||||
int ret, count;
|
||||
struct ltdb_search_info *sinfo;
|
||||
|
||||
sinfo = talloc_p(ltdb, struct ltdb_search_info);
|
||||
sinfo = talloc(ltdb, struct ltdb_search_info);
|
||||
if (sinfo == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ static int ltdb_delete(struct ldb_module *module, const char *dn)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
msg = talloc_p(module, struct ldb_message);
|
||||
msg = talloc(module, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
@ -368,7 +368,7 @@ static int msg_add_element(struct ldb_context *ldb,
|
||||
struct ldb_message_element *e2;
|
||||
unsigned int i;
|
||||
|
||||
e2 = talloc_realloc_p(msg, msg->elements, struct ldb_message_element,
|
||||
e2 = talloc_realloc(msg, msg->elements, struct ldb_message_element,
|
||||
msg->num_elements+1);
|
||||
if (!e2) {
|
||||
errno = ENOMEM;
|
||||
@ -383,7 +383,7 @@ static int msg_add_element(struct ldb_context *ldb,
|
||||
e2->flags = el->flags;
|
||||
e2->values = NULL;
|
||||
if (el->num_values != 0) {
|
||||
e2->values = talloc_array_p(msg->elements, struct ldb_val, el->num_values);
|
||||
e2->values = talloc_array(msg->elements, struct ldb_val, el->num_values);
|
||||
if (!e2->values) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
@ -422,7 +422,7 @@ static int msg_delete_attribute(struct ldb_module *module,
|
||||
}
|
||||
msg->num_elements--;
|
||||
i--;
|
||||
msg->elements = talloc_realloc_p(msg, msg->elements,
|
||||
msg->elements = talloc_realloc(msg, msg->elements,
|
||||
struct ldb_message_element,
|
||||
msg->num_elements);
|
||||
}
|
||||
@ -498,7 +498,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg2 = talloc_p(tdb_key.dptr, struct ldb_message);
|
||||
msg2 = talloc(tdb_key.dptr, struct ldb_message);
|
||||
if (msg2 == NULL) {
|
||||
talloc_free(tdb_key.dptr);
|
||||
return -1;
|
||||
@ -547,7 +547,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
|
||||
}
|
||||
}
|
||||
|
||||
vals = talloc_realloc_p(msg2->elements, el2->values, struct ldb_val,
|
||||
vals = talloc_realloc(msg2->elements, el2->values, struct ldb_val,
|
||||
el2->num_values + el->num_values);
|
||||
|
||||
if (vals == NULL)
|
||||
@ -661,7 +661,7 @@ static int ltdb_rename(struct ldb_module *module, const char *olddn, const char
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = talloc_p(module, struct ldb_message);
|
||||
msg = talloc(module, struct ldb_message);
|
||||
if (msg == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
@ -765,7 +765,7 @@ struct ldb_context *ltdb_connect(const char *url,
|
||||
TDB_CONTEXT *tdb;
|
||||
struct ldb_context *ldb;
|
||||
|
||||
ldb = talloc_zero_p(NULL, struct ldb_context);
|
||||
ldb = talloc_zero(NULL, struct ldb_context);
|
||||
if (!ldb) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
@ -798,7 +798,7 @@ struct ldb_context *ltdb_connect(const char *url,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ltdb = talloc_zero_p(ldb, struct ltdb_private);
|
||||
ltdb = talloc_zero(ldb, struct ltdb_private);
|
||||
if (!ltdb) {
|
||||
tdb_close(tdb);
|
||||
talloc_free(ldb);
|
||||
@ -811,7 +811,7 @@ struct ldb_context *ltdb_connect(const char *url,
|
||||
|
||||
talloc_set_destructor(ltdb, ltdb_destructor);
|
||||
|
||||
ldb->modules = talloc_p(ldb, struct ldb_module);
|
||||
ldb->modules = talloc(ldb, struct ldb_module);
|
||||
if (!ldb->modules) {
|
||||
talloc_free(ldb);
|
||||
errno = ENOMEM;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -74,11 +74,11 @@ static int add_time_element(struct ldb_module *module, struct ldb_message *msg,
|
||||
}
|
||||
}
|
||||
|
||||
msg->elements = talloc_realloc_p(msg, msg->elements,
|
||||
msg->elements = talloc_realloc(msg, msg->elements,
|
||||
struct ldb_message_element, msg->num_elements + 1);
|
||||
name = talloc_strdup(msg->elements, attr_name);
|
||||
timestr = talloc_strdup(msg->elements, time_string);
|
||||
values = talloc_p(msg->elements, struct ldb_val);
|
||||
values = talloc(msg->elements, struct ldb_val);
|
||||
if (!msg->elements || !name || !timestr || !values) {
|
||||
return -1;
|
||||
}
|
||||
@ -113,7 +113,7 @@ static int timestamps_add_record(struct ldb_module *module, const struct ldb_mes
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg2 = talloc_p(module, struct ldb_message);
|
||||
msg2 = talloc(module, struct ldb_message);
|
||||
if (!msg2) {
|
||||
return -1;
|
||||
}
|
||||
@ -130,7 +130,7 @@ static int timestamps_add_record(struct ldb_module *module, const struct ldb_mes
|
||||
msg2->dn = msg->dn;
|
||||
msg2->num_elements = msg->num_elements;
|
||||
msg2->private_data = msg->private_data;
|
||||
msg2->elements = talloc_array_p(msg2, struct ldb_message_element, msg2->num_elements);
|
||||
msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
|
||||
for (i = 0; i < msg2->num_elements; i++) {
|
||||
msg2->elements[i] = msg->elements[i];
|
||||
}
|
||||
@ -169,7 +169,7 @@ static int timestamps_modify_record(struct ldb_module *module, const struct ldb_
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg2 = talloc_p(module, struct ldb_message);
|
||||
msg2 = talloc(module, struct ldb_message);
|
||||
if (!msg2) {
|
||||
return -1;
|
||||
}
|
||||
@ -187,7 +187,7 @@ static int timestamps_modify_record(struct ldb_module *module, const struct ldb_
|
||||
msg2->dn = msg->dn;
|
||||
msg2->num_elements = msg->num_elements;
|
||||
msg2->private_data = msg->private_data;
|
||||
msg2->elements = talloc_array_p(msg2, struct ldb_message_element, msg2->num_elements);
|
||||
msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
|
||||
for (i = 0; i < msg2->num_elements; i++) {
|
||||
msg2->elements[i] = msg->elements[i];
|
||||
}
|
||||
@ -272,11 +272,11 @@ struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *o
|
||||
struct ldb_module *ctx;
|
||||
struct private_data *data;
|
||||
|
||||
ctx = talloc_p(ldb, struct ldb_module);
|
||||
ctx = talloc(ldb, struct ldb_module);
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
data = talloc_p(ctx, struct private_data);
|
||||
data = talloc(ctx, struct private_data);
|
||||
if (!data) {
|
||||
talloc_free(ctx);
|
||||
return NULL;
|
||||
|
@ -280,7 +280,7 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int coun
|
||||
}
|
||||
|
||||
while ((ldif = ldb_ldif_read_file(ldb, f))) {
|
||||
msgs2 = talloc_realloc_p(ldb, msgs2, struct ldb_message *, count2+1);
|
||||
msgs2 = talloc_realloc(ldb, msgs2, struct ldb_message *, count2+1);
|
||||
if (!msgs2) {
|
||||
fprintf(stderr, "out of memory");
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user