summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-10-25 20:57:18 +0200
committerStefan Metzmacher <metze@samba.org>2009-11-06 14:05:40 +0100
commitb54ec122b2f75fe74356ee73c18e3a76e28c7294 (patch)
tree61d9d1d4f3b202c9ee96f1b6f1f44c39c4548fae /source4
parent6210237b5aebce71e210dbe39cdf71593e6c03af (diff)
downloadsamba-b54ec122b2f75fe74356ee73c18e3a76e28c7294.tar.gz
samba-b54ec122b2f75fe74356ee73c18e3a76e28c7294.tar.bz2
samba-b54ec122b2f75fe74356ee73c18e3a76e28c7294.zip
s4/drs: Move schema_prefixMap allocation in separate function
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/schema/schema_prefixmap.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/source4/dsdb/schema/schema_prefixmap.c b/source4/dsdb/schema/schema_prefixmap.c
index 9bc6bfd112..326628e95e 100644
--- a/source4/dsdb/schema/schema_prefixmap.c
+++ b/source4/dsdb/schema/schema_prefixmap.c
@@ -25,11 +25,36 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "../lib/util/asn1.h"
+
+/**
+ * Allocates schema_prefixMap object in supplied memory context
+ */
+static struct dsdb_schema_prefixmap *_dsdb_schema_prefixmap_talloc(TALLOC_CTX *mem_ctx,
+ uint32_t length)
+{
+ struct dsdb_schema_prefixmap *pfm;
+
+ pfm = talloc_zero(mem_ctx, struct dsdb_schema_prefixmap);
+ if (!pfm) {
+ return NULL;
+ }
+
+ pfm->length = length;
+ pfm->prefixes = talloc_zero_array(pfm, struct dsdb_schema_prefixmap_oid,
+ pfm->length);
+ if (!pfm->prefixes) {
+ talloc_free(pfm);
+ return NULL;
+ }
+
+ return pfm;
+}
+
/**
* Initial prefixMap creation according to:
* [MS-DRSR] section 5.12.2
*/
-WERROR dsdb_schema_pfm_new(TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap **ppfm)
+WERROR dsdb_schema_pfm_new(TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap **_pfm)
{
uint32_t i;
struct dsdb_schema_prefixmap *pfm;
@@ -59,13 +84,9 @@ WERROR dsdb_schema_pfm_new(TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap **p
};
/* allocate mem for prefix map */
- pfm = talloc_zero(mem_ctx, struct dsdb_schema_prefixmap);
+ pfm = _dsdb_schema_prefixmap_talloc(mem_ctx, ARRAY_SIZE(pfm_init_data));
W_ERROR_HAVE_NO_MEMORY(pfm);
- pfm->length = ARRAY_SIZE(pfm_init_data);
- pfm->prefixes = talloc_array(pfm, struct dsdb_schema_prefixmap_oid, pfm->length);
- W_ERROR_HAVE_NO_MEMORY(pfm->prefixes);
-
/* build prefixes */
for (i = 0; i < pfm->length; i++) {
if (!ber_write_partial_OID_String(pfm, &pfm->prefixes[i].bin_oid, pfm_init_data[i].oid_prefix)) {
@@ -75,7 +96,7 @@ WERROR dsdb_schema_pfm_new(TALLOC_CTX *mem_ctx, struct dsdb_schema_prefixmap **p
pfm->prefixes[i].id = pfm_init_data[i].id;
}
- *ppfm = pfm;
+ *_pfm = pfm;
return WERR_OK;
}
@@ -384,16 +405,9 @@ WERROR dsdb_schema_pfm_from_drsuapi_pfm(const struct drsuapi_DsReplicaOIDMapping
W_ERROR_NOT_OK_RETURN(werr);
/* allocate mem for prefix map */
- pfm = talloc_zero(mem_ctx, struct dsdb_schema_prefixmap);
+ pfm = _dsdb_schema_prefixmap_talloc(mem_ctx, ctr->num_mappings - 1);
W_ERROR_HAVE_NO_MEMORY(pfm);
- pfm->length = ctr->num_mappings - 1;
- pfm->prefixes = talloc_array(pfm, struct dsdb_schema_prefixmap_oid, pfm->length);
- if (!pfm->prefixes) {
- talloc_free(pfm);
- return WERR_NOMEM;
- }
-
/* copy entries from drsuapi_prefixMap */
for (i = 0; i < pfm->length; i++) {
blob = data_blob_talloc(pfm,