summaryrefslogtreecommitdiff
path: root/lib/talloc
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-07-02 09:29:20 -0400
committerSimo Sorce <idra@samba.org>2009-07-03 08:45:29 -0400
commit2738178d1301f9c1c4144c7472c9419911cd816e (patch)
tree7e40836e4677f27d4b7244c462cc71ff80a7820b /lib/talloc
parentb54e48b830dbc3d66f9de5d2711a57a1630809e2 (diff)
downloadsamba-2738178d1301f9c1c4144c7472c9419911cd816e.tar.gz
samba-2738178d1301f9c1c4144c7472c9419911cd816e.tar.bz2
samba-2738178d1301f9c1c4144c7472c9419911cd816e.zip
Restore ABI compatibility for talloc.
Diffstat (limited to 'lib/talloc')
-rwxr-xr-xlib/talloc/abi_checks.sh6
-rw-r--r--lib/talloc/configure.ac2
-rw-r--r--lib/talloc/talloc.c43
-rw-r--r--lib/talloc/talloc.exports6
-rw-r--r--lib/talloc/talloc.h14
-rw-r--r--lib/talloc/talloc.signatures95
6 files changed, 106 insertions, 60 deletions
diff --git a/lib/talloc/abi_checks.sh b/lib/talloc/abi_checks.sh
index 432cc87745..e3d3b042fa 100755
--- a/lib/talloc/abi_checks.sh
+++ b/lib/talloc/abi_checks.sh
@@ -4,15 +4,17 @@ make clean
mkdir abi
ABI_CHECKS="-aux-info abi/\$@.X"
-make ABI_CHECK="$ABI_CHECKS"
+make ABI_CHECK="$ABI_CHECKS" CC="/usr/bin/gcc"
-for i in abi/*.X; do cat $i | grep 'talloc\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' > abi/signatures
+for i in abi/*.X; do cat $i | grep 'talloc\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' | sort > abi/signatures
cat > abi/exports << EOF
{
global:
EOF
cat abi/signatures | awk -F '(' '{ print $1 }' | awk -F ' ' '{ print " "$NF";" }' | tr -d '*' | sort >> abi/exports
+# need to manually add talloc free for backward ABI compat
+echo ' talloc_free;' >> abi/exports
cat >> abi/exports << EOF
local: *;
diff --git a/lib/talloc/configure.ac b/lib/talloc/configure.ac
index d6471a4aa7..161f6f79e3 100644
--- a/lib/talloc/configure.ac
+++ b/lib/talloc/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.50)
-AC_INIT(talloc, 2.0.0)
+AC_INIT(talloc, 1.4.0)
AC_CONFIG_SRCDIR([talloc.c])
AC_SUBST(datarootdir)
AC_CONFIG_HEADER(config.h)
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index a23df38b56..8ccebe2e24 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -477,7 +477,7 @@ static inline void *_talloc_named_const(const void *context, size_t size, const
same underlying data, and you want to be able to free the two instances separately,
and in either order
*/
-void *_talloc_reference(const void *context, const void *ptr, const char *location)
+void *_talloc_reference_loc(const void *context, const void *ptr, const char *location)
{
struct talloc_chunk *tc;
struct talloc_reference_handle *handle;
@@ -499,6 +499,7 @@ void *_talloc_reference(const void *context, const void *ptr, const char *locati
return handle->ptr;
}
+static void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
/*
internal talloc_free call
@@ -613,7 +614,7 @@ static inline int _talloc_free_internal(void *ptr)
ptr on success, or NULL if it could not be transferred.
passing NULL as ptr will always return NULL with no side effects.
*/
-void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
+static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
{
struct talloc_chunk *tc, *new_tc;
@@ -665,13 +666,12 @@ void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
return discard_const_p(void, ptr);
}
-
/*
move a lump of memory from one talloc context to another return the
ptr on success, or NULL if it could not be transferred.
passing NULL as ptr will always return NULL with no side effects.
*/
-void *_talloc_steal(const void *new_ctx, const void *ptr, const char *location)
+void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location)
{
struct talloc_chunk *tc;
@@ -683,9 +683,13 @@ void *_talloc_steal(const void *new_ctx, const void *ptr, const char *location)
if (unlikely(tc->refs != NULL) && talloc_parent(ptr) != new_ctx) {
struct talloc_reference_handle *h;
+#if DEVELOPER
fprintf(stderr, "ERROR: talloc_steal with references at %s\n", location);
+#endif
for (h=tc->refs; h; h=h->next) {
+#if DEVELOPER
fprintf(stderr, "\treference at %s\n", h->location);
+#endif
}
return NULL;
}
@@ -1054,9 +1058,13 @@ int _talloc_free(void *ptr, const char *location)
if (unlikely(tc->refs != NULL)) {
struct talloc_reference_handle *h;
+#if DEVELOPER
fprintf(stderr, "ERROR: talloc_free with references at %s\n", location);
+#endif
for (h=tc->refs; h; h=h->next) {
+#if DEVELOPER
fprintf(stderr, "\treference at %s\n", h->location);
+#endif
}
return -1;
}
@@ -1876,3 +1884,30 @@ int talloc_is_parent(const void *context, const void *ptr)
}
return 0;
}
+
+
+
+
+/* ABI compat functions (do NOT append anything beyond thess functions,
+ * keep them as the last ones in the file) */
+
+static const char *talloc_ABI_compat_location = "Called from compatibility function";
+
+/* ABI compat function (don't use) */
+void *_talloc_reference(const void *context, const void *ptr) {
+ return _talloc_reference_loc(context, ptr, talloc_ABI_compat_location);
+}
+
+/* ABI compat function (don't use) */
+void *_talloc_steal(const void *new_ctx, const void *ptr)
+{
+ return _talloc_steal_internal(new_ctx, ptr);
+}
+
+#undef talloc_free
+int talloc_free(void *ptr)
+{
+ return _talloc_free_internal(ptr);
+}
+
+/* DO NOT APPEND ANYTHING BEYOND THIS POINT */
diff --git a/lib/talloc/talloc.exports b/lib/talloc/talloc.exports
index b7878453cf..2459c48211 100644
--- a/lib/talloc/talloc.exports
+++ b/lib/talloc/talloc.exports
@@ -12,7 +12,7 @@
talloc_enable_leak_report_full;
talloc_enable_null_tracking;
talloc_find_parent_byname;
- talloc_free;
+ _talloc_free;
talloc_free_children;
talloc_get_name;
talloc_get_size;
@@ -32,6 +32,8 @@
talloc_realloc_fn;
_talloc_reference;
talloc_reference_count;
+ _talloc_reference_loc;
+ talloc_reparent;
talloc_report;
talloc_report_depth_cb;
talloc_report_depth_file;
@@ -42,6 +44,7 @@
talloc_set_name_const;
talloc_show_parents;
_talloc_steal;
+ _talloc_steal_loc;
talloc_strdup;
talloc_strdup_append;
talloc_strdup_append_buffer;
@@ -56,6 +59,7 @@
talloc_vasprintf_append_buffer;
_talloc_zero;
_talloc_zero_array;
+ talloc_free;
local: *;
};
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 9d1aa0df04..855f778f8c 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -69,15 +69,15 @@ typedef void TALLOC_CTX;
} while(0)
/* this extremely strange macro is to avoid some braindamaged warning
stupidity in gcc 4.1.x */
-#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr), __location__); __talloc_steal_ret; })
+#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__); __talloc_steal_ret; })
#else
#define talloc_set_destructor(ptr, function) \
_talloc_set_destructor((ptr), (int (*)(void *))(function))
#define _TALLOC_TYPEOF(ptr) void *
-#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr), __location__)
+#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__)
#endif
-#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr), __location__)
+#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__)
#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
/* useful macros for creating type checked pointers */
@@ -126,7 +126,7 @@ void *talloc_pool(const void *context, size_t size);
void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *));
int talloc_increase_ref_count(const void *ptr);
size_t talloc_reference_count(const void *ptr);
-void *_talloc_reference(const void *context, const void *ptr, const char *location);
+void *_talloc_reference_loc(const void *context, const void *ptr, const char *location);
int talloc_unlink(const void *context, void *ptr);
const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void talloc_set_name_const(const void *ptr, const char *name);
@@ -142,8 +142,7 @@ void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
int _talloc_free(void *ptr, const char *location);
void talloc_free_children(void *ptr);
void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name);
-void *_talloc_steal(const void *new_ctx, const void *ptr, const char *location);
-void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
+void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location);
void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr);
void *_talloc_move(const void *new_ctx, const void *pptr);
size_t talloc_total_size(const void *ptr);
@@ -191,4 +190,7 @@ char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIB
void talloc_set_abort_fn(void (*abort_fn)(const char *reason));
+/* for ABI compatibility, never use in new code */
+void *_talloc_reference(const void *context, const void *ptr);
+void *_talloc_steal(const void *new_ctx, const void *ptr);
#endif
diff --git a/lib/talloc/talloc.signatures b/lib/talloc/talloc.signatures
index e2fc8aee43..96b71f737a 100644
--- a/lib/talloc/talloc.signatures
+++ b/lib/talloc/talloc.signatures
@@ -1,56 +1,59 @@
-void *_talloc (const void *, size_t);
-void *talloc_pool (const void *, size_t);
-void _talloc_set_destructor (const void *, int (*) (void *));
+char *talloc_asprintf_append_buffer (char *, const char *, ...);
+char *talloc_asprintf_append (char *, const char *, ...);
+char *talloc_asprintf (const void *, const char *, ...);
+char *talloc_strdup_append_buffer (char *, const char *);
+char *talloc_strdup_append (char *, const char *);
+char *talloc_strdup (const void *, const char *);
+char *talloc_strndup_append_buffer (char *, const char *, size_t);
+char *talloc_strndup_append (char *, const char *, size_t);
+char *talloc_strndup (const void *, const char *, size_t);
+char *talloc_vasprintf_append_buffer (char *, const char *, va_list);
+char *talloc_vasprintf_append (char *, const char *, va_list);
+char *talloc_vasprintf (const void *, const char *, va_list);
+const char *talloc_get_name (const void *);
+const char *talloc_parent_name (const void *);
+const char *talloc_set_name (const void *, const char *, ...);
+int _talloc_free (void *, const char *);
int talloc_increase_ref_count (const void *);
-size_t talloc_reference_count (const void *);
-void *_talloc_reference (const void *, const void *);
+int talloc_is_parent (const void *, const void *);
int talloc_unlink (const void *, void *);
-const char *talloc_set_name (const void *, const char *, ...);
-void talloc_set_name_const (const void *, const char *);
-void *talloc_named (const void *, size_t, const char *, ...);
-void *talloc_named_const (const void *, size_t, const char *);
-const char *talloc_get_name (const void *);
+size_t talloc_get_size (const void *);
+size_t talloc_reference_count (const void *);
+size_t talloc_total_blocks (const void *);
+size_t talloc_total_size (const void *);
+void *_talloc_array (const void *, size_t, unsigned int, const char *);
+void *talloc_autofree_context (void);
void *talloc_check_name (const void *, const char *);
+void *_talloc (const void *, size_t);
+void talloc_disable_null_tracking (void);
+void talloc_enable_leak_report_full (void);
+void talloc_enable_leak_report (void);
+void talloc_enable_null_tracking (void);
+void *talloc_find_parent_byname (const void *, const char *);
+void talloc_free_children (void *);
void *_talloc_get_type_abort (const void *, const char *, const char *);
-void *talloc_parent (const void *);
-const char *talloc_parent_name (const void *);
void *talloc_init (const char *, ...);
-int talloc_free (void *);
-void talloc_free_children (void *);
-void *_talloc_realloc (const void *, void *, size_t, const char *);
-void *_talloc_steal (const void *, const void *);
+void *_talloc_memdup (const void *, const void *, size_t, const char *);
void *_talloc_move (const void *, const void *);
-size_t talloc_total_size (const void *);
-size_t talloc_total_blocks (const void *);
+void *talloc_named_const (const void *, size_t, const char *);
+void *talloc_named (const void *, size_t, const char *, ...);
+void *talloc_parent (const void *);
+void *talloc_pool (const void *, size_t);
+void *_talloc_realloc_array (const void *, void *, size_t, unsigned int, const char *);
+void *_talloc_realloc (const void *, void *, size_t, const char *);
+void *talloc_realloc_fn (const void *, void *, size_t);
+void *_talloc_reference (const void *, const void *);
+void *_talloc_reference_loc (const void *, const void *, const char *);
+void *talloc_reparent (const void *, const void *, const void *);
+void talloc_report (const void *, FILE *);
void talloc_report_depth_cb (const void *, int, int, void (*) (const void *, int, int, int, void *), void *);
void talloc_report_depth_file (const void *, int, int, FILE *);
void talloc_report_full (const void *, FILE *);
-void talloc_report (const void *, FILE *);
-void talloc_enable_null_tracking (void);
-void talloc_disable_null_tracking (void);
-void talloc_enable_leak_report (void);
-void talloc_enable_leak_report_full (void);
-void *_talloc_zero (const void *, size_t, const char *);
-void *_talloc_memdup (const void *, const void *, size_t, const char *);
-void *_talloc_array (const void *, size_t, unsigned int, const char *);
-void *_talloc_zero_array (const void *, size_t, unsigned int, const char *);
-void *_talloc_realloc_array (const void *, void *, size_t, unsigned int, const char *);
-void *talloc_realloc_fn (const void *, void *, size_t);
-void *talloc_autofree_context (void);
-size_t talloc_get_size (const void *);
-void *talloc_find_parent_byname (const void *, const char *);
-void talloc_show_parents (const void *, FILE *);
-int talloc_is_parent (const void *, const void *);
-char *talloc_strdup (const void *, const char *);
-char *talloc_strdup_append (char *, const char *);
-char *talloc_strdup_append_buffer (char *, const char *);
-char *talloc_strndup (const void *, const char *, size_t);
-char *talloc_strndup_append (char *, const char *, size_t);
-char *talloc_strndup_append_buffer (char *, const char *, size_t);
-char *talloc_vasprintf (const void *, const char *, __va_list_tag *);
-char *talloc_vasprintf_append (char *, const char *, __va_list_tag *);
-char *talloc_vasprintf_append_buffer (char *, const char *, __va_list_tag *);
-char *talloc_asprintf (const void *, const char *, ...);
-char *talloc_asprintf_append (char *, const char *, ...);
-char *talloc_asprintf_append_buffer (char *, const char *, ...);
void talloc_set_abort_fn (void (*) (const char *));
+void _talloc_set_destructor (const void *, int (*) (void *));
+void talloc_set_name_const (const void *, const char *);
+void talloc_show_parents (const void *, FILE *);
+void *_talloc_steal (const void *, const void *);
+void *_talloc_steal_loc (const void *, const void *, const char *);
+void *_talloc_zero_array (const void *, size_t, unsigned int, const char *);
+void *_talloc_zero (const void *, size_t, const char *);