summaryrefslogtreecommitdiff
path: root/source3/lib/netapi
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-08-01 16:44:05 +0200
committerGünther Deschner <gd@samba.org>2008-08-11 19:03:49 +0200
commite480162e5b44cd9705b05a0bf9d64894309a7ae4 (patch)
treedb3143816c3c774a338d1be2472eb45d18560b5b /source3/lib/netapi
parentc7c35108105eea60e3cf81f2d53d241889349c91 (diff)
downloadsamba-e480162e5b44cd9705b05a0bf9d64894309a7ae4.tar.gz
samba-e480162e5b44cd9705b05a0bf9d64894309a7ae4.tar.bz2
samba-e480162e5b44cd9705b05a0bf9d64894309a7ae4.zip
netapi: add NetApiBufferAllocate.
Guenther (This used to be commit 99cc8f023b4ad9210b677e11371f404048752031)
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r--source3/lib/netapi/netapi.c27
-rw-r--r--source3/lib/netapi/netapi.h6
2 files changed, 33 insertions, 0 deletions
diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c
index 7d78aa8120..889388173f 100644
--- a/source3/lib/netapi/netapi.c
+++ b/source3/lib/netapi/netapi.c
@@ -309,6 +309,33 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
/****************************************************************
****************************************************************/
+NET_API_STATUS NetApiBufferAllocate(uint32_t byte_count,
+ void **buffer)
+{
+ void *buf = NULL;
+
+ if (!buffer) {
+ return W_ERROR_V(WERR_INSUFFICIENT_BUFFER);
+ }
+
+ if (byte_count == 0) {
+ goto done;
+ }
+
+ buf = talloc_size(NULL, byte_count);
+ if (!buf) {
+ return W_ERROR_V(WERR_NOMEM);
+ }
+
+ done:
+ *buffer = buf;
+
+ return NET_API_STATUS_SUCCESS;
+}
+
+/****************************************************************
+****************************************************************/
+
NET_API_STATUS NetApiBufferFree(void *buffer)
{
if (!buffer) {
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 2c6b667123..9cc8e9eca4 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -400,6 +400,12 @@ const char *libnetapi_errstr(NET_API_STATUS status);
const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
NET_API_STATUS status);
+/****************************************************************
+ NetApiBufferAllocate
+****************************************************************/
+
+NET_API_STATUS NetApiBufferAllocate(uint32_t byte_count,
+ void **buffer);
/****************************************************************
NetApiBufferFree