summaryrefslogtreecommitdiffstats
path: root/source/lib/util.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-10-29 22:14:17 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-10-29 22:14:17 +0000
commitb02ed7ee195ebd9060f91e117c002d661b6cc9d6 (patch)
tree92025186d508e372c1ddffab0951d26c3ac8ab35 /source/lib/util.c
parentfd1d0064b3a4fe834c5d8e810a12a8077f9d2a66 (diff)
downloadsamba-b02ed7ee195ebd9060f91e117c002d661b6cc9d6.tar.gz
samba-b02ed7ee195ebd9060f91e117c002d661b6cc9d6.tar.xz
samba-b02ed7ee195ebd9060f91e117c002d661b6cc9d6.zip
Add a bit of 'const' for the data_blob code.
Add a new data_blob_clear_free() function - that zero's out the buffer when its done.
Diffstat (limited to 'source/lib/util.c')
-rw-r--r--source/lib/util.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index af0a6bda718..920c8e9db8e 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -1659,7 +1659,7 @@ void *xmalloc(size_t size)
Memdup with smb_panic on fail.
*****************************************************************/
-void *xmemdup(void *p, size_t size)
+void *xmemdup(const void *p, size_t size)
{
void *p2;
p2 = xmalloc(size);
@@ -1682,7 +1682,7 @@ char *xstrdup(const char *s)
/*****************************************************************
like strdup but for memory
*****************************************************************/
-void *memdup(void *p, size_t size)
+void *memdup(const void *p, size_t size)
{
void *p2;
if (size == 0) return NULL;
@@ -1934,7 +1934,7 @@ BOOL unix_wild_match(char *pattern, char *string)
/*******************************************************************
construct a data blob, must be freed with data_blob_free()
*******************************************************************/
-DATA_BLOB data_blob(void *p, size_t length)
+DATA_BLOB data_blob(const void *p, size_t length)
{
DATA_BLOB ret;
@@ -1956,6 +1956,16 @@ void data_blob_free(DATA_BLOB *d)
SAFE_FREE(d->data);
}
+/*******************************************************************
+free a data blob and clear its contents
+*******************************************************************/
+void data_blob_clear_free(DATA_BLOB *d)
+{
+ if (d->data) {
+ memset((char *)&(d->data), 0, d->length);
+ }
+ data_blob_free(d);
+}
#ifdef __INSURE__