inspired by http://swapped.cc/halloc/
*/
-
+#if defined(HAVE_CONFIG_H)
#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#else
/* nfsim additions */
#define HAVE_SYS_TYPES_H
#define HAVE_UNISTD_H
#define HAVE_STDARG_H
#define HAVE_STDINT_H
#define HAVE_VA_COPY
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !defined(NDEBUG)
+#include <assert.h>
+#define TALLOC_ABORT(reason) do{ \
+ fprintf(stderr, "%s: name: %s\n", __func__, tc->name); \
+ assert(0 && reason);} while (0)
+#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
/*
return the number of external references to a pointer
*/
-static int talloc_reference_count(const void *ptr)
+int talloc_reference_count(const void *ptr)
{
struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr);
struct talloc_reference_handle *h;
talloc_set_name_const(ret, ret);
}
+ va_end(ap2);
return ret;
}
len = vsnprintf(NULL, 0, fmt, ap2);
s = talloc_realloc(NULL, s, char, s_len + len+1);
- if (!s) return NULL;
+ if (!s)
+ goto out;
VA_COPY(ap2, ap);
vsnprintf(s+s_len, len+1, fmt, ap2);
talloc_set_name_const(s, s);
+out:
+ va_end(ap2);
return s;
}