svn commit: samba r2653 - in branches/SAMBA_4_0/source: include lib
tridge at samba.org
tridge at samba.org
Sun Sep 26 06:41:59 GMT 2004
Author: tridge
Date: 2004-09-26 06:41:59 +0000 (Sun, 26 Sep 2004)
New Revision: 2653
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=2653&nolog=1
Log:
- data_blob() and data_blob_talloc() now get automatic names
- talloc_strdup() and related functions get automatic names
Modified:
branches/SAMBA_4_0/source/include/talloc.h
branches/SAMBA_4_0/source/lib/data_blob.c
branches/SAMBA_4_0/source/lib/talloc.c
Changeset:
Modified: branches/SAMBA_4_0/source/include/talloc.h
===================================================================
--- branches/SAMBA_4_0/source/include/talloc.h 2004-09-26 06:28:06 UTC (rev 2652)
+++ branches/SAMBA_4_0/source/include/talloc.h 2004-09-26 06:41:59 UTC (rev 2653)
@@ -38,6 +38,7 @@
#define talloc_p(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__)
#define talloc_realloc_p(p, type, count) (type *)talloc_realloc_array(p, sizeof(type), count, __location__)
+#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
#define talloc_destroy(ctx) talloc_free(ctx)
@@ -45,5 +46,7 @@
#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
#define realloc_p(p, type, count) (type *)realloc_array(p, sizeof(type), count)
+#define data_blob(ptr, size) data_blob_named(ptr, size, __location__)
+
#endif
Modified: branches/SAMBA_4_0/source/lib/data_blob.c
===================================================================
--- branches/SAMBA_4_0/source/lib/data_blob.c 2004-09-26 06:28:06 UTC (rev 2652)
+++ branches/SAMBA_4_0/source/lib/data_blob.c 2004-09-26 06:41:59 UTC (rev 2653)
@@ -25,7 +25,7 @@
construct a data blob, must be freed with data_blob_free()
you can pass NULL for p and get a blank data blob
*******************************************************************/
-DATA_BLOB data_blob(const void *p, size_t length)
+DATA_BLOB data_blob_named(const void *p, size_t length, const char *name)
{
DATA_BLOB ret;
@@ -43,6 +43,7 @@
ret.length = 0;
return ret;
}
+ talloc_set_name_const(ret.data, name);
ret.length = length;
return ret;
}
Modified: branches/SAMBA_4_0/source/lib/talloc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc.c 2004-09-26 06:28:06 UTC (rev 2652)
+++ branches/SAMBA_4_0/source/lib/talloc.c 2004-09-26 06:41:59 UTC (rev 2653)
@@ -26,9 +26,6 @@
#include "includes.h"
-#undef talloc
-#define talloc(ctx, size) _talloc(ctx, size)
-
#define MAX_TALLOC_SIZE 0x10000000
#define TALLOC_MAGIC 0xe814ec4f
#define TALLOC_MAGIC_FREE 0x7faebef3
@@ -171,7 +168,7 @@
va_list ap;
void *ptr;
- ptr = talloc(context, size);
+ ptr = _talloc(context, size);
if (ptr == NULL) {
return NULL;
}
@@ -192,7 +189,7 @@
{
void *ptr;
- ptr = talloc(context, size);
+ ptr = _talloc(context, size);
if (ptr == NULL) {
return NULL;
}
@@ -222,7 +219,7 @@
va_list ap;
void *ptr;
- ptr = talloc(NULL, 0);
+ ptr = _talloc(NULL, 0);
if (ptr == NULL) {
return NULL;
}
@@ -438,7 +435,7 @@
*/
void talloc_enable_leak_check(void)
{
- null_context = talloc_named(NULL, 0, "null_context");
+ null_context = talloc_named_const(NULL, 0, "null_context");
atexit(talloc_report_all);
}
@@ -460,12 +457,13 @@
/*
memdup with a talloc.
*/
-void *talloc_memdup(void *t, const void *p, size_t size)
+void *_talloc_memdup(void *t, const void *p, size_t size, const char *name)
{
- void *newp = talloc(t,size);
+ void *newp = _talloc(t,size);
if (newp) {
memcpy(newp, p, size);
+ talloc_set_name_const(newp, name);
}
return newp;
@@ -476,10 +474,15 @@
*/
char *talloc_strdup(void *t, const char *p)
{
+ char *ret;
if (!p) {
return NULL;
}
- return talloc_memdup(t, p, strlen(p) + 1);
+ ret = talloc_memdup(t, p, strlen(p) + 1);
+ if (ret) {
+ talloc_set_name_const(ret, ret);
+ }
+ return ret;
}
/*
@@ -511,6 +514,7 @@
if (ret) {
VA_COPY(ap2, ap);
vsnprintf(ret, len+1, fmt, ap2);
+ talloc_set_name_const(ret, ret);
}
return ret;
@@ -563,6 +567,7 @@
VA_COPY(ap2, ap);
vsnprintf(s+s_len, len+1, fmt, ap2);
+ talloc_set_name_const(s, s);
return s;
}
More information about the samba-cvs
mailing list