summaryrefslogtreecommitdiff
path: root/source3
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
commit53ec47a209364db0861b85f8c70922168b271a6b (patch)
tree7248a3922919e3193d783e245a98078c05e656c1 /source3
parente5cee57941154130edbe65fd1250ca78bb0a2f5b (diff)
downloadsamba-53ec47a209364db0861b85f8c70922168b271a6b.tar.gz
samba-53ec47a209364db0861b85f8c70922168b271a6b.tar.bz2
samba-53ec47a209364db0861b85f8c70922168b271a6b.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. (This used to be commit b02ed7ee195ebd9060f91e117c002d661b6cc9d6)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index af0a6bda71..920c8e9db8 100644
--- a/source3/lib/util.c
+++ b/source3/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__