s3-librpc: Add dcerpc_binding_vector_new().
authorAndreas Schneider <asn@samba.org>
Thu, 30 Jun 2011 09:52:59 +0000 (11:52 +0200)
committerAndreas Schneider <asn@samba.org>
Mon, 1 Aug 2011 06:50:34 +0000 (08:50 +0200)
source3/librpc/rpc/dcerpc_ep.c
source3/librpc/rpc/dcerpc_ep.h

index 14d475fbef44b011f69d10fada461a730661ae1d..cd8b656a7b72e21356b1bca7505c7b1267a2d2e8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Endpoint Mapper Functions
  *  DCERPC local endpoint mapper client routines
- *  Copyright (c) 2010      Andreas Schneider.
+ *  Copyright (c) 2010-2011 Andreas Schneider.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 #define EPM_MAX_ANNOTATION_SIZE 64
 
+NTSTATUS dcerpc_binding_vector_new(TALLOC_CTX *mem_ctx,
+                                  struct dcerpc_binding_vector **pbvec)
+{
+       struct dcerpc_binding_vector *bvec;
+       NTSTATUS status;
+       TALLOC_CTX *tmp_ctx;
+
+       tmp_ctx = talloc_stackframe();
+       if (tmp_ctx == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       bvec = talloc_zero(tmp_ctx, struct dcerpc_binding_vector);
+       if (bvec == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto done;
+       }
+
+       bvec->bindings = talloc_zero_array(bvec,
+                                          struct dcerpc_binding,
+                                          4);
+       if (bvec->bindings == NULL) {
+               status = NT_STATUS_NO_MEMORY;
+               goto done;
+       }
+
+       bvec->allocated = 4;
+       bvec->count = 0;
+
+       *pbvec = talloc_move(mem_ctx, &bvec);
+
+       status = NT_STATUS_OK;
+done:
+       talloc_free(tmp_ctx);
+
+       return status;
+}
+
 NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
                                      const struct ndr_interface_table *iface,
                                      uint16_t port,
index 226d402986e1e72aee0003dc93b8dfaf83ac10c1..61b85e23dc0ac34f61d4b7fa4a267ec0c4d9a84b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Endpoint Mapper Functions
  *  DCERPC local endpoint mapper client routines
- *  Copyright (c) 2010      Andreas Schneider.
+ *  Copyright (c) 2010-2011 Andreas Schneider.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 struct dcerpc_binding_vector {
     struct dcerpc_binding *bindings;
     uint32_t count;
+    uint32_t allocated;
 };
 
+/**
+ * @brief Allocate a new binding vector.
+ *
+ * @param[in]  mem_ctx  The memory context to allocate the vector.
+ *
+ * @param[out] pbvec    A pointer to store the binding vector.
+ *
+ * @return              An NTSTATUS error code.
+ */
+NTSTATUS dcerpc_binding_vector_new(TALLOC_CTX *mem_ctx,
+                                  struct dcerpc_binding_vector **pbvec);
+
 NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
                                      const struct ndr_interface_table *iface,
                                      uint16_t port,