Parcourir la source

libdpkg: Factor out new m_vasprintf() from m_asprintf()

Guillem Jover il y a 13 ans
Parent
commit
670e9d691f
3 fichiers modifiés avec 17 ajouts et 4 suppressions
  1. 2 0
      lib/dpkg/dpkg.h
  2. 1 0
      lib/dpkg/libdpkg.map
  3. 14 4
      lib/dpkg/mlib.c

+ 2 - 0
lib/dpkg/dpkg.h

@@ -145,6 +145,8 @@ void *m_realloc(void *, size_t);
 char *m_strdup(const char *str);
 char *m_strndup(const char *str, size_t n);
 int m_asprintf(char **strp, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
+int m_vasprintf(char **strp, const char *fmt, va_list args)
+	DPKG_ATTR_VPRINTF(2);
 void m_dup2(int oldfd, int newfd);
 void m_pipe(int fds[2]);
 void m_output(FILE *f, const char *name);

+ 1 - 0
lib/dpkg/libdpkg.map

@@ -62,6 +62,7 @@ LIBDPKG_PRIVATE {
 	m_calloc;
 	m_realloc;
 	m_strdup;
+	m_vasprintf;
 	m_asprintf;
 	m_dup2;
 	m_pipe;

+ 14 - 4
lib/dpkg/mlib.c

@@ -84,14 +84,11 @@ m_strndup(const char *str, size_t n)
 }
 
 int
-m_asprintf(char **strp, const char *fmt, ...)
+m_vasprintf(char **strp, const char *fmt, va_list args)
 {
-  va_list args;
   int n;
 
-  va_start(args, fmt);
   n = vasprintf(strp, fmt, args);
-  va_end(args);
 
   onerr_abort++;
   if (n < 0)
@@ -101,6 +98,19 @@ m_asprintf(char **strp, const char *fmt, ...)
   return n;
 }
 
+int
+m_asprintf(char **strp, const char *fmt, ...)
+{
+  va_list args;
+  int n;
+
+  va_start(args, fmt);
+  n = m_vasprintf(strp, fmt, args);
+  va_end(args);
+
+  return n;
+}
+
 void m_dup2(int oldfd, int newfd) {
   const char *const stdstrings[]= { "in", "out", "err" };