From e480162e5b44cd9705b05a0bf9d64894309a7ae4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Fri, 1 Aug 2008 16:44:05 +0200 Subject: [PATCH] netapi: add NetApiBufferAllocate. Guenther (This used to be commit 99cc8f023b4ad9210b677e11371f404048752031) --- source3/lib/netapi/netapi.c | 27 +++++++++++++++++++++++++++ source3/lib/netapi/netapi.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 7d78aa8120a..889388173f0 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 2c6b667123f..9cc8e9eca4e 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 -- 2.11.4.GIT