diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2010-07-14 20:48:40 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2010-07-14 20:48:40 +0000 |
commit | 5186b553a5a5183eea7b54afd0ad538ae8538c64 (patch) | |
tree | 908d8342cb2fd59e5cd8672d9c09a5c908ae3426 /libgphoto2_port/libgphoto2_port | |
parent | 84914ece81036abf4ac63dbcc8f7e826035a506b (diff) | |
download | libgphoto2-5186b553a5a5183eea7b54afd0ad538ae8538c64.tar.gz |
Fixed uses of va_copy to call va_free, and to compile even when va_copy
isn't available
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@13147 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'libgphoto2_port/libgphoto2_port')
-rw-r--r-- | libgphoto2_port/libgphoto2_port/gphoto2-port-log.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c b/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c index 26572469e..4973fb986 100644 --- a/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c +++ b/libgphoto2_port/libgphoto2_port/gphoto2-port-log.c @@ -263,6 +263,8 @@ gp_logv (GPLogLevel level, const char *domain, const char *format, int i; #ifdef HAVE_VA_COPY va_list xargs; +#else +#define xargs args #endif int strsize = 1000; char *str; @@ -277,16 +279,26 @@ gp_logv (GPLogLevel level, const char *domain, const char *format, va_copy (xargs, args); #endif n = vsnprintf (str, strsize, format, xargs); +#ifdef HAVE_VA_COPY + va_end(xargs); +#endif if (n+1>strsize) { free (str); str = malloc(n+1); - if (!str) return; + if (!str) { + va_end(args); + return; + } strsize = n+1; #ifdef HAVE_VA_COPY va_copy (xargs, args); #endif n = vsnprintf (str, strsize, format, xargs); +#ifdef HAVE_VA_COPY + va_end(xargs); +#endif } + va_end(args); for (i = 0; i < log_funcs_count; i++) if (log_funcs[i].level >= level) log_funcs[i].func (level, domain, str, log_funcs[i].data); |