summaryrefslogtreecommitdiff
path: root/libgphoto2_port
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2022-11-07 09:19:08 +0100
committerMarcus Meissner <marcus@jet.franken.de>2022-11-07 09:19:35 +0100
commitc03aa04db07650a087b3188181bc10cc9451cad7 (patch)
tree4cd6fa60309ae6c7678e9f50019970487ec26b21 /libgphoto2_port
parent3067c978af62f34cce4b366f4723c137227b9059 (diff)
downloadlibgphoto2-c03aa04db07650a087b3188181bc10cc9451cad7.tar.gz
always build gpi_vsnprintf, as we use it unconditionally in libgphoto2
fixes https://github.com/gphoto/libgphoto2/issues/174
Diffstat (limited to 'libgphoto2_port')
-rw-r--r--libgphoto2_port/libgphoto2_port/gphoto2-port-log.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c b/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c
index f7770bede..7cc7614f8 100644
--- a/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c
+++ b/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c
@@ -35,6 +35,35 @@
#include "libgphoto2_port/i18n.h"
+char*
+gpi_vsnprintf (const char* format, va_list args)
+{
+ va_list xargs;
+ int strsize;
+ char *str;
+
+#ifdef HAVE_VA_COPY
+ va_copy (xargs, args);
+#else
+ /* according to 'the web', the only interesting compiler without va_copy is MSVC
+ * and there a simple assignment is the way to go */
+ xargs = args;
+#endif
+
+ /* query the size necessary for the string, add the terminating '\0' */
+ strsize = vsnprintf (NULL, 0, format, xargs) + 1;
+ va_end (xargs);
+
+ str = malloc(strsize);
+ if (!str)
+ return NULL;
+
+ /* actually print the string into the buffer */
+ vsnprintf (str, strsize, format, args);
+
+ return str;
+}
+
#ifndef DISABLE_DEBUGGING
/**
* \brief Internal logging function entry.
@@ -85,35 +114,6 @@ gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data)
}
-char*
-gpi_vsnprintf (const char* format, va_list args)
-{
- va_list xargs;
- int strsize;
- char *str;
-
-#ifdef HAVE_VA_COPY
- va_copy (xargs, args);
-#else
- /* according to 'the web', the only interesting compiler without va_copy is MSVC
- * and there a simple assignment is the way to go */
- xargs = args;
-#endif
-
- /* query the size necessary for the string, add the terminating '\0' */
- strsize = vsnprintf (NULL, 0, format, xargs) + 1;
- va_end (xargs);
-
- str = malloc(strsize);
- if (!str)
- return NULL;
-
- /* actually print the string into the buffer */
- vsnprintf (str, strsize, format, args);
-
- return str;
-}
-
/**
* \brief Remove a logging receiving function
* \param id an id (return value of #gp_log_add_func)