]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Move talloc_asprintf_addbuf() to talloc
authorVolker Lendecke <vl@samba.org>
Mon, 28 Nov 2022 09:19:54 +0000 (10:19 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 14 Dec 2022 04:32:34 +0000 (04:32 +0000)
I wanted to use this in debug.c, but this would have meant to pollute
debug's deps with a lot of stuff. Also, looking through uses of
talloc_asprint_append(), very many of those don't do NULL checks
properly and could benefit from the _addbuf() flavor. We can add a
vasprintf variant later if the need shows up.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/talloc/ABI/pytalloc-util-2.3.5.sigs [new file with mode: 0644]
lib/talloc/ABI/talloc-2.3.5.sigs [new file with mode: 0644]
lib/talloc/talloc.c
lib/talloc/talloc.h
lib/talloc/wscript
lib/util/samba_util.h
lib/util/util_str.c

diff --git a/lib/talloc/ABI/pytalloc-util-2.3.5.sigs b/lib/talloc/ABI/pytalloc-util-2.3.5.sigs
new file mode 100644 (file)
index 0000000..6056577
--- /dev/null
@@ -0,0 +1,16 @@
+_pytalloc_check_type: int (PyObject *, const char *)
+_pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
+_pytalloc_get_name: const char *(PyObject *)
+_pytalloc_get_ptr: void *(PyObject *)
+_pytalloc_get_type: void *(PyObject *, const char *)
+pytalloc_BaseObject_PyType_Ready: int (PyTypeObject *)
+pytalloc_BaseObject_check: int (PyObject *)
+pytalloc_BaseObject_size: size_t (void)
+pytalloc_Check: int (PyObject *)
+pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
+pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
+pytalloc_GetBaseObjectType: PyTypeObject *(void)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
diff --git a/lib/talloc/ABI/talloc-2.3.5.sigs b/lib/talloc/ABI/talloc-2.3.5.sigs
new file mode 100644 (file)
index 0000000..ec3cee4
--- /dev/null
@@ -0,0 +1,66 @@
+_talloc: void *(const void *, size_t)
+_talloc_array: void *(const void *, size_t, unsigned int, const char *)
+_talloc_free: int (void *, const char *)
+_talloc_get_type_abort: void *(const void *, const char *, const char *)
+_talloc_memdup: void *(const void *, const void *, size_t, const char *)
+_talloc_move: void *(const void *, const void *)
+_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
+_talloc_realloc: void *(const void *, void *, size_t, const char *)
+_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
+_talloc_reference_loc: void *(const void *, const void *, const char *)
+_talloc_set_destructor: void (const void *, int (*)(void *))
+_talloc_steal_loc: void *(const void *, const void *, const char *)
+_talloc_zero: void *(const void *, size_t, const char *)
+_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
+talloc_asprintf: char *(const void *, const char *, ...)
+talloc_asprintf_addbuf: void (char **, const char *, ...)
+talloc_asprintf_append: char *(char *, const char *, ...)
+talloc_asprintf_append_buffer: char *(char *, const char *, ...)
+talloc_autofree_context: void *(void)
+talloc_check_name: void *(const void *, const char *)
+talloc_disable_null_tracking: void (void)
+talloc_enable_leak_report: void (void)
+talloc_enable_leak_report_full: void (void)
+talloc_enable_null_tracking: void (void)
+talloc_enable_null_tracking_no_autofree: void (void)
+talloc_find_parent_byname: void *(const void *, const char *)
+talloc_free_children: void (void *)
+talloc_get_name: const char *(const void *)
+talloc_get_size: size_t (const void *)
+talloc_increase_ref_count: int (const void *)
+talloc_init: void *(const char *, ...)
+talloc_is_parent: int (const void *, const void *)
+talloc_named: void *(const void *, size_t, const char *, ...)
+talloc_named_const: void *(const void *, size_t, const char *)
+talloc_parent: void *(const void *)
+talloc_parent_name: const char *(const void *)
+talloc_pool: void *(const void *, size_t)
+talloc_realloc_fn: void *(const void *, void *, size_t)
+talloc_reference_count: size_t (const void *)
+talloc_reparent: void *(const void *, const void *, const void *)
+talloc_report: void (const void *, FILE *)
+talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
+talloc_report_depth_file: void (const void *, int, int, FILE *)
+talloc_report_full: void (const void *, FILE *)
+talloc_set_abort_fn: void (void (*)(const char *))
+talloc_set_log_fn: void (void (*)(const char *))
+talloc_set_log_stderr: void (void)
+talloc_set_memlimit: int (const void *, size_t)
+talloc_set_name: const char *(const void *, const char *, ...)
+talloc_set_name_const: void (const void *, const char *)
+talloc_show_parents: void (const void *, FILE *)
+talloc_strdup: char *(const void *, const char *)
+talloc_strdup_append: char *(char *, const char *)
+talloc_strdup_append_buffer: char *(char *, const char *)
+talloc_strndup: char *(const void *, const char *, size_t)
+talloc_strndup_append: char *(char *, const char *, size_t)
+talloc_strndup_append_buffer: char *(char *, const char *, size_t)
+talloc_test_get_magic: int (void)
+talloc_total_blocks: size_t (const void *)
+talloc_total_size: size_t (const void *)
+talloc_unlink: int (const void *, void *)
+talloc_vasprintf: char *(const void *, const char *, va_list)
+talloc_vasprintf_append: char *(char *, const char *, va_list)
+talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
+talloc_version_major: int (void)
+talloc_version_minor: int (void)
index 29da190880ab05eec91b8461d2501502985243cf..0189fa03be0f8258a58034554f8ca8a8461b51ae 100644 (file)
@@ -2752,6 +2752,29 @@ _PUBLIC_ char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...)
        return s;
 }
 
+_PUBLIC_ void talloc_asprintf_addbuf(char **ps, const char *fmt, ...)
+{
+       va_list ap;
+       char *s = *ps;
+       char *t = NULL;
+
+       if (s == NULL) {
+               return;
+       }
+
+       va_start(ap, fmt);
+       t = talloc_vasprintf_append_buffer(s, fmt, ap);
+       va_end(ap);
+
+       if (t == NULL) {
+               /* signal failure to the next caller */
+               TALLOC_FREE(s);
+               *ps = NULL;
+       } else {
+               *ps = t;
+       }
+}
+
 /*
   alloc an array, checking for integer overflow in the array size
 */
index 06e81d7c9995afb47ff5113e640920eb179ee81f..dba9a3e9db90729781b52e8509aa5ef441c17b5b 100644 (file)
@@ -1578,6 +1578,20 @@ _PUBLIC_ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRI
  */
 _PUBLIC_ char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
 
+/**
+ * @brief Build up a string buffer, handle allocation failure
+ *
+ * @param[in] ps Pointer to the talloc'ed string to be extended
+ * @param[in] fmt The format string
+ * @param[in] ... The parameters used to fill fmt.
+ *
+ * This does nothing if *ps is NULL and sets *ps to NULL if the
+ * intermediate reallocation fails. Useful when building up a string
+ * step by step, no intermediate NULL checks are required.
+ */
+_PUBLIC_ void talloc_asprintf_addbuf(char **ps, const char *fmt, ...) \
+       PRINTF_ATTRIBUTE(2,3);
+
 /**
  * @brief Format a string.
  *
index 30896636404de34ad52a022e2d9b9f89569b3783..5a9779cf2d80276de6ba70d2ab7fafc4bd3c2318 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'talloc'
-VERSION = '2.3.4'
+VERSION = '2.3.5'
 
 import os
 import sys
index 4762a7c523f3f1041511a1123d0095319459d3ca..d8c8522616d723373f9cf03b3d4d63a8e30254b6 100644 (file)
@@ -327,20 +327,6 @@ _PUBLIC_ bool conv_str_u64(const char * str, uint64_t * val);
  */
 _PUBLIC_ bool mem_equal_const_time(const void *s1, const void *s2, size_t n);
 
-/**
- * @brief Build up a string buffer, handle allocation failure
- *
- * @param[in] ps Pointer to the talloc'ed string to be extended
- * @param[in] fmt The format string
- * @param[in] ... The parameters used to fill fmt.
- *
- * This does nothing if *ps is NULL and sets *ps to NULL if the
- * intermediate reallocation fails. Useful when building up a string
- * step by step, no intermediate NULL checks are required.
- */
-
-_PUBLIC_ void talloc_asprintf_addbuf(char **ps, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-
 /**
 Do a case-insensitive, whitespace-ignoring string compare.
 **/
index a0f95348bc1785cce2293335d3fcea94ee7ae150..833eb754918176e2c54301866dd5c9f3efb90f1e 100644 (file)
@@ -305,26 +305,3 @@ _PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean)
        }
        return false;
 }
-
-_PUBLIC_ void talloc_asprintf_addbuf(char **ps, const char *fmt, ...)
-{
-       va_list ap;
-       char *s = *ps;
-       char *t = NULL;
-
-       if (s == NULL) {
-               return;
-       }
-
-       va_start(ap, fmt);
-       t = talloc_vasprintf_append_buffer(s, fmt, ap);
-       va_end(ap);
-
-       if (t == NULL) {
-               /* signal failure to the next caller */
-               TALLOC_FREE(s);
-               *ps = NULL;
-       } else {
-               *ps = t;
-       }
-}