Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -3,6 +3,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Overridable allocator support enabled */
#undef ENABLE_OVERRIDABLE_ALLOCATORS
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H

View File

@@ -1 +1 @@
e6c748208dd33485e04939f7cbb59545aa05f3a3
801fdd9c4cde828e7e92456ad7de345487765e0b

View File

@@ -138,6 +138,15 @@ AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf)
AC_CHECK_FUNCS(getrlimit)
AC_CHECK_FUNCS(fork execv execve)
AC_ARG_WITH([overridable-allocators], [ --with-overridable-allocators allow g_*alloc/g_free to call custom allocators set via g_mem_set_vtable])
if test x$with_overridable_allocators = xyes; then
AC_DEFINE(ENABLE_OVERRIDABLE_ALLOCATORS,1,[Overridable allocator support enabled])
AC_MSG_NOTICE([Overridable allocator support enabled])
else
AC_MSG_NOTICE([Overridable allocator support disabled])
fi
#
# Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding
# the detection of strndup on OS X so Mono built on 10.7+ still runs on 10.6. This can be
@@ -151,7 +160,7 @@ elif test x$target_ios = xno; then
AC_CHECK_FUNCS(strndup getpwuid_r)
fi
AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno )
AM_CONDITIONAL(NEED_VASPRINTF, test x$ac_cv_func_vasprintf = xno || test x$with_overridable_allocators = xyes)
AM_ICONV()
AC_SEARCH_LIBS(sqrtf, m)

View File

@@ -11,14 +11,6 @@ unix_files = \
gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c \
gmodule-unix.c gtimer-unix.c
# some unices and windows do not have an implementation of vasprintf
# used by eglib, use provided implementation instead
if NEED_VASPRINTF
vasprintf_files = vasprintf.c
else
vaprinttf_files = foo.c
endif
if HOST_WIN32
os_files = $(win_files)
else
@@ -32,7 +24,6 @@ libeglib_la_SOURCES = \
garray.c \
gbytearray.c \
gerror.c \
vasprintf.h \
ghashtable.c \
giconv.c \
gmem.c \
@@ -55,8 +46,7 @@ libeglib_la_SOURCES = \
gutf8.c \
gunicode.c \
unicode-data.h \
$(os_files) \
$(vasprintf_files)
$(os_files)
libeglib_la_CFLAGS = -g -Wall -D_FORTIFY_SOURCE=2

View File

@@ -100,14 +100,14 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
am__DEPENDENCIES_1 =
@HOST_WIN32_TRUE@libeglib_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__libeglib_la_SOURCES_DIST = eglib-remap.h sort.frag.h glib.h \
garray.c gbytearray.c gerror.c vasprintf.h ghashtable.c \
giconv.c gmem.c gmodule.h goutput.c gqsort.c gstr.c gslist.c \
gstring.c gptrarray.c glist.c gqueue.c gpath.c gshell.c \
gspawn.c gfile.c gfile-posix.c gpattern.c gmarkup.c gutf8.c \
gunicode.c unicode-data.h gdate-unix.c gdir-unix.c \
gfile-unix.c gmisc-unix.c gmodule-unix.c gtimer-unix.c \
eglib-config.hw gdate-win32.c gdir-win32.c gfile-win32.c \
gmisc-win32.c gmodule-win32.c gtimer-win32.c vasprintf.c
garray.c gbytearray.c gerror.c ghashtable.c giconv.c gmem.c \
gmodule.h goutput.c gqsort.c gstr.c gslist.c gstring.c \
gptrarray.c glist.c gqueue.c gpath.c gshell.c gspawn.c gfile.c \
gfile-posix.c gpattern.c gmarkup.c gutf8.c gunicode.c \
unicode-data.h gdate-unix.c gdir-unix.c gfile-unix.c \
gmisc-unix.c gmodule-unix.c gtimer-unix.c eglib-config.hw \
gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \
gmodule-win32.c gtimer-win32.c
am__objects_1 = libeglib_la-gdate-unix.lo libeglib_la-gdir-unix.lo \
libeglib_la-gfile-unix.lo libeglib_la-gmisc-unix.lo \
libeglib_la-gmodule-unix.lo libeglib_la-gtimer-unix.lo
@@ -116,7 +116,6 @@ am__objects_2 = libeglib_la-gdate-win32.lo libeglib_la-gdir-win32.lo \
libeglib_la-gmodule-win32.lo libeglib_la-gtimer-win32.lo
@HOST_WIN32_FALSE@am__objects_3 = $(am__objects_1)
@HOST_WIN32_TRUE@am__objects_3 = $(am__objects_2)
@NEED_VASPRINTF_TRUE@am__objects_4 = libeglib_la-vasprintf.lo
am_libeglib_la_OBJECTS = libeglib_la-garray.lo \
libeglib_la-gbytearray.lo libeglib_la-gerror.lo \
libeglib_la-ghashtable.lo libeglib_la-giconv.lo \
@@ -128,8 +127,7 @@ am_libeglib_la_OBJECTS = libeglib_la-garray.lo \
libeglib_la-gshell.lo libeglib_la-gspawn.lo \
libeglib_la-gfile.lo libeglib_la-gfile-posix.lo \
libeglib_la-gpattern.lo libeglib_la-gmarkup.lo \
libeglib_la-gutf8.lo libeglib_la-gunicode.lo $(am__objects_3) \
$(am__objects_4)
libeglib_la-gutf8.lo libeglib_la-gunicode.lo $(am__objects_3)
libeglib_la_OBJECTS = $(am_libeglib_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -353,11 +351,6 @@ unix_files = \
gdate-unix.c gdir-unix.c gfile-unix.c gmisc-unix.c \
gmodule-unix.c gtimer-unix.c
# some unices and windows do not have an implementation of vasprintf
# used by eglib, use provided implementation instead
@NEED_VASPRINTF_TRUE@vasprintf_files = vasprintf.c
@NEED_VASPRINTF_FALSE@vaprinttf_files = foo.c
@HOST_WIN32_FALSE@os_files = $(unix_files)
@HOST_WIN32_TRUE@os_files = $(win_files)
libeglib_la_SOURCES = \
@@ -367,7 +360,6 @@ libeglib_la_SOURCES = \
garray.c \
gbytearray.c \
gerror.c \
vasprintf.h \
ghashtable.c \
giconv.c \
gmem.c \
@@ -390,8 +382,7 @@ libeglib_la_SOURCES = \
gutf8.c \
gunicode.c \
unicode-data.h \
$(os_files) \
$(vasprintf_files)
$(os_files)
libeglib_la_CFLAGS = -g -Wall -D_FORTIFY_SOURCE=2
AM_CPPFLAGS = -I$(srcdir)
@@ -491,7 +482,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeglib_la-gtimer-win32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeglib_la-gunicode.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeglib_la-gutf8.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeglib_la-vasprintf.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -759,13 +749,6 @@ libeglib_la-gtimer-win32.lo: gtimer-win32.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeglib_la_CFLAGS) $(CFLAGS) -c -o libeglib_la-gtimer-win32.lo `test -f 'gtimer-win32.c' || echo '$(srcdir)/'`gtimer-win32.c
libeglib_la-vasprintf.lo: vasprintf.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeglib_la_CFLAGS) $(CFLAGS) -MT libeglib_la-vasprintf.lo -MD -MP -MF $(DEPDIR)/libeglib_la-vasprintf.Tpo -c -o libeglib_la-vasprintf.lo `test -f 'vasprintf.c' || echo '$(srcdir)/'`vasprintf.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeglib_la-vasprintf.Tpo $(DEPDIR)/libeglib_la-vasprintf.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='vasprintf.c' object='libeglib_la-vasprintf.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeglib_la_CFLAGS) $(CFLAGS) -c -o libeglib_la-vasprintf.lo `test -f 'vasprintf.c' || echo '$(srcdir)/'`vasprintf.c
mostlyclean-libtool:
-rm -f *.lo

View File

@@ -28,10 +28,8 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <config.h>
#include <glib.h>
#include "vasprintf.h"
GError *
g_error_new (gpointer domain, gint code, const char *format, ...)
{
@@ -42,7 +40,7 @@ g_error_new (gpointer domain, gint code, const char *format, ...)
err->code = code;
va_start (args, format);
if (vasprintf (&err->message, format, args) == -1)
if (g_vasprintf (&err->message, format, args) == -1)
err->message = g_strdup_printf ("internal: invalid format string %s", format);
va_end (args);
@@ -57,7 +55,7 @@ g_error_vnew (gpointer domain, gint code, const char *format, va_list ap)
err->domain = domain;
err->code = code;
if (vasprintf (&err->message, format, ap) == -1)
if (g_vasprintf (&err->message, format, ap) == -1)
err->message = g_strdup_printf ("internal: invalid format string %s", format);
return err;
@@ -77,7 +75,7 @@ g_error_free (GError *error)
{
g_return_if_fail (error != NULL);
free (error->message);
g_free (error->message);
g_free (error);
}

View File

@@ -35,6 +35,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <direct.h>
#ifdef G_OS_WIN32
#include <io.h>
@@ -68,6 +69,26 @@ int mkstemp (char *tmp_template)
return fd;
}
gchar *
g_mkdtemp (char *tmp_template)
{
gunichar2* utf16_template;
utf16_template = u8to16 (tmp_template);
utf16_template = _wmktemp(utf16_template);
if (utf16_template && *utf16_template) {
if (_wmkdir (utf16_template) == 0){
char *ret = u16to8 (utf16_template);
g_free (utf16_template);
return ret;
}
}
g_free (utf16_template);
return NULL;
}
#ifdef _MSC_VER
#pragma warning(disable:4701)
#endif

View File

@@ -199,8 +199,11 @@ g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft,
} else {
outleftptr = NULL;
}
#if defined(__NetBSD__)
return iconv (cd->cd, (const gchar **)inbytes, inleftptr, outbytes, outleftptr);
#else
return iconv (cd->cd, inbytes, inleftptr, outbytes, outleftptr);
#endif
}
#endif

View File

@@ -1,6 +1,5 @@
#ifndef __GLIB_H
#define __GLIB_H
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -9,6 +8,7 @@
#include <ctype.h>
#include <limits.h>
#ifdef _MSC_VER
#pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
#endif
@@ -126,6 +126,7 @@ void g_free (void *ptr);
gpointer g_realloc (gpointer obj, gsize size);
gpointer g_malloc (gsize x);
gpointer g_malloc0 (gsize x);
gpointer g_calloc (gsize n, gsize x);
gpointer g_try_malloc (gsize x);
gpointer g_try_realloc (gpointer obj, gsize size);
@@ -138,7 +139,7 @@ gpointer g_try_realloc (gpointer obj, gsize size);
#define g_alloca(size) alloca (size)
gpointer g_memdup (gconstpointer mem, guint byte_size);
static inline gchar *g_strdup (const gchar *str) { if (str) {return strdup (str);} return NULL; }
static inline gchar *g_strdup (const gchar *str) { if (str) { return (gchar*) g_memdup (str, (guint)strlen (str) + 1); } return NULL; }
gchar **g_strdupv (gchar **str_array);
typedef struct {
@@ -146,11 +147,9 @@ typedef struct {
gpointer (*realloc) (gpointer mem, gsize n_bytes);
void (*free) (gpointer mem);
gpointer (*calloc) (gsize n_blocks, gsize n_block_bytes);
gpointer (*try_malloc) (gsize n_bytes);
gpointer (*try_realloc) (gpointer mem, gsize n_bytes);
} GMemVTable;
#define g_mem_set_vtable(x)
void g_mem_set_vtable (GMemVTable* vtable);
struct _GMemChunk {
guint alloc_size;
@@ -223,11 +222,11 @@ gint g_printf (gchar const *format, ...);
gint g_fprintf (FILE *file, gchar const *format, ...);
gint g_sprintf (gchar *string, gchar const *format, ...);
gint g_snprintf (gchar *string, gulong n, gchar const *format, ...);
gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap);
#define g_vprintf vprintf
#define g_vfprintf vfprintf
#define g_vsprintf vsprintf
#define g_vsnprintf vsnprintf
#define g_vasprintf vasprintf
gsize g_strlcpy (gchar *dest, const gchar *src, gsize dest_size);
gchar *g_stpcpy (gchar *dest, const char *src);
@@ -888,6 +887,12 @@ gboolean g_file_test (const gchar *filename, GFileTest test);
#define g_ascii_strtod strtod
#define g_ascii_isalnum isalnum
#ifdef WIN32
gchar *g_mkdtemp (gchar *tmpl);
#else
#define g_mkdtemp mkdtemp
#endif
/*
* Pattern matching
*/

View File

@@ -367,7 +367,7 @@ g_markup_parse_context_parse (GMarkupParseContext *context,
if (context->parser.end_element != NULL && context->state == START_ELEMENT){
context->parser.end_element (context, ename, context->user_data, error);
if (error != NULL && *error != NULL){
free (ename);
g_free (ename);
goto fail;
}
}

View File

@@ -25,15 +25,45 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#if defined (ENABLE_OVERRIDABLE_ALLOCATORS)
static GMemVTable sGMemVTable = { malloc, realloc, free, calloc };
void
g_mem_set_vtable (GMemVTable* vtable)
{
sGMemVTable.calloc = vtable->calloc ? vtable->calloc : calloc;
sGMemVTable.realloc = vtable->realloc ? vtable->realloc : realloc;
sGMemVTable.malloc = vtable->malloc ? vtable->malloc : malloc;
sGMemVTable.free = vtable->free ? vtable->free : free;
}
#define G_FREE_INTERNAL sGMemVTable.free
#define G_REALLOC_INTERNAL sGMemVTable.realloc
#define G_CALLOC_INTERNAL sGMemVTable.calloc
#define G_MALLOC_INTERNAL sGMemVTable.malloc
#else
void
g_mem_set_vtable (GMemVTable* vtable)
{
}
#define G_FREE_INTERNAL free
#define G_REALLOC_INTERNAL realloc
#define G_CALLOC_INTERNAL calloc
#define G_MALLOC_INTERNAL malloc
#endif
void
g_free (void *ptr)
{
if (ptr != NULL)
free (ptr);
G_FREE_INTERNAL (ptr);
}
gpointer
@@ -58,7 +88,7 @@ gpointer g_realloc (gpointer obj, gsize size)
g_free (obj);
return 0;
}
ptr = realloc (obj, size);
ptr = G_REALLOC_INTERNAL (obj, size);
if (ptr)
return ptr;
g_error ("Could not allocate %i bytes", size);
@@ -70,27 +100,31 @@ g_malloc (gsize x)
gpointer ptr;
if (!x)
return 0;
ptr = malloc (x);
ptr = G_MALLOC_INTERNAL (x);
if (ptr)
return ptr;
g_error ("Could not allocate %i bytes", x);
}
gpointer g_calloc (gsize n, gsize x)
{
gpointer ptr;
if (!x || !n)
return 0;
ptr = G_CALLOC_INTERNAL (n, x);
if (ptr)
return ptr;
g_error ("Could not allocate %i (%i * %i) bytes", x*n, n, x);
}
gpointer g_malloc0 (gsize x)
{
gpointer ptr;
if (!x)
return 0;
ptr = calloc(1,x);
if (ptr)
return ptr;
g_error ("Could not allocate %i bytes", x);
return g_calloc (1,x);
}
gpointer g_try_malloc (gsize x)
{
if (x)
return malloc (x);
return G_MALLOC_INTERNAL (x);
return 0;
}
@@ -98,8 +132,8 @@ gpointer g_try_malloc (gsize x)
gpointer g_try_realloc (gpointer obj, gsize size)
{
if (!size) {
g_free (obj);
G_FREE_INTERNAL (obj);
return 0;
}
return realloc (obj, size);
return G_REALLOC_INTERNAL (obj, size);
}

View File

@@ -30,6 +30,9 @@
#include <glib.h>
#include <windows.h>
#ifdef _MSC_VER
#include <shlobj.h>
#endif
#include <direct.h>
#include <io.h>
@@ -89,10 +92,10 @@ g_win32_getlocale(void)
{
LCID lcid = GetThreadLocale();
gchar buf[19];
gint ccBuf = GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, buf, 9);
gint ccBuf = GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, buf, 9);
buf[ccBuf - 1] = '-';
ccBuf += GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
return strdup(buf);
ccBuf += GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
return g_strdup (buf);
}
gboolean
@@ -116,16 +119,33 @@ g_path_is_absolute (const char *filename)
const gchar *
g_get_home_dir (void)
{
/* FIXME */
const gchar *drive = g_getenv ("HOMEDRIVE");
const gchar *path = g_getenv ("HOMEPATH");
gchar *home_dir = NULL;
if (drive && path) {
home_dir = g_malloc(strlen(drive) + strlen(path) +1);
if (home_dir) {
sprintf(home_dir, "%s%s", drive, path);
#ifdef _MSC_VER
PWSTR profile_path = NULL;
HRESULT hr = SHGetKnownFolderPath (&FOLDERID_Profile, KF_FLAG_DEFAULT, NULL, &profile_path);
if (SUCCEEDED(hr)) {
home_dir = u16to8 (profile_path);
CoTaskMemFree (profile_path);
}
#endif
if (!home_dir) {
home_dir = (gchar *) g_getenv ("USERPROFILE");
}
if (!home_dir) {
const gchar *drive = g_getenv ("HOMEDRIVE");
const gchar *path = g_getenv ("HOMEPATH");
if (drive && path) {
home_dir = g_malloc (strlen (drive) + strlen (path) + 1);
if (home_dir) {
sprintf (home_dir, "%s%s", drive, path);
}
}
g_free (drive);
g_free (path);
}
return home_dir;

View File

@@ -31,8 +31,6 @@
#include <stdlib.h>
#include <glib.h>
#include "vasprintf.h"
/* The current fatal levels, error is always fatal */
static GLogLevelFlags fatal = G_LOG_LEVEL_ERROR;
static GLogFunc default_log_func;
@@ -49,7 +47,7 @@ g_print (const gchar *format, ...)
va_list args;
va_start (args, format);
if (vasprintf (&msg, format, args) < 0)
if (g_vasprintf (&msg, format, args) < 0)
return;
va_end (args);
@@ -57,7 +55,7 @@ g_print (const gchar *format, ...)
stdout_handler = default_stdout_handler;
stdout_handler (msg);
free (msg);
g_free (msg);
}
void
@@ -67,7 +65,7 @@ g_printerr (const gchar *format, ...)
va_list args;
va_start (args, format);
if (vasprintf (&msg, format, args) < 0)
if (g_vasprintf (&msg, format, args) < 0)
return;
va_end (args);
@@ -75,7 +73,7 @@ g_printerr (const gchar *format, ...)
stderr_handler = default_stderr_handler;
stderr_handler (msg);
free (msg);
g_free (msg);
}
GLogLevelFlags
@@ -107,11 +105,11 @@ g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format,
if (!default_log_func)
default_log_func = g_log_default_handler;
if (vasprintf (&msg, format, args) < 0)
if (g_vasprintf (&msg, format, args) < 0)
return;
default_log_func (log_domain, log_level, msg, default_log_func_user_data);
free (msg);
g_free (msg);
}
void

View File

@@ -32,13 +32,17 @@
#include <ctype.h>
#include <glib.h>
#include "vasprintf.h"
/*
* g_strndup and g_vasprintf need to allocate memory with g_malloc if
* ENABLE_OVERRIDABLE_ALLOCATORS is defined so that it can be safely freed with g_free
* rather than free.
*/
/* This is not a macro, because I dont want to put _GNU_SOURCE in the glib.h header */
gchar *
g_strndup (const gchar *str, gsize n)
{
#ifdef HAVE_STRNDUP
#if defined (HAVE_STRNDUP) && !defined (ENABLE_OVERRIDABLE_ALLOCATORS)
return strndup (str, n);
#else
if (str) {
@@ -52,6 +56,37 @@ g_strndup (const gchar *str, gsize n)
#endif
}
gint g_vasprintf (gchar **ret, const gchar *fmt, va_list ap)
{
#if defined (HAVE_VASPRINTF) && !defined (ENABLE_OVERRIDABLE_ALLOCATORS)
return vasprintf (ret, fmt, ap);
#else
char *buf;
int len;
size_t buflen;
va_list ap2;
#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
ap2 = ap;
len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
#else
va_copy(ap2, ap);
len = vsnprintf(NULL, 0, fmt, ap2);
#endif
if (len >= 0 && (buf = g_malloc ((buflen = (size_t) (len + 1)))) != NULL) {
len = vsnprintf(buf, buflen, fmt, ap);
*ret = buf;
} else {
*ret = NULL;
len = -1;
}
va_end(ap2);
return len;
#endif
}
void
g_strfreev (gchar **str_array)
{
@@ -133,7 +168,7 @@ g_strdup_vprintf (const gchar *format, va_list args)
int n;
char *ret;
n = vasprintf (&ret, format, args);
n = g_vasprintf (&ret, format, args);
if (n == -1)
return NULL;
@@ -148,7 +183,7 @@ g_strdup_printf (const gchar *format, ...)
int n;
va_start (args, format);
n = vasprintf (&ret, format, args);
n = g_vasprintf (&ret, format, args);
va_end (args);
if (n == -1)
return NULL;

View File

@@ -1,31 +0,0 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
int vasprintf(char **ret, const char *fmt, va_list ap)
{
char *buf;
int len;
size_t buflen;
va_list ap2;
#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
ap2 = ap;
len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
#else
va_copy(ap2, ap);
len = vsnprintf(NULL, 0, fmt, ap2);
#endif
if (len >= 0 && (buf = malloc ((buflen = (size_t) (len + 1)))) != NULL) {
len = vsnprintf(buf, buflen, fmt, ap);
*ret = buf;
} else {
*ret = NULL;
len = -1;
}
va_end(ap2);
return len;
}

View File

@@ -1,11 +0,0 @@
#ifndef __VASPRINTF_H
#define __VASPRINTF_H
#include <stdarg.h>
#include <config.h>
#ifndef HAVE_VASPRINTF
int vasprintf(char **ret, const char *fmt, va_list ap);
#endif
#endif /* __VASPRINTF_H */

View File

@@ -46,13 +46,6 @@
#include "test.h"
extern gint global_passed, global_tests;
#ifndef HAVE_VASPRINTF
/* systen does not provide a vasprintf function, use the one
provided within eglib itself */
extern int vasprintf(char **ret, const char *format, va_list ap);
#endif
static gchar *last_result = NULL;
gboolean
@@ -183,7 +176,7 @@ FAILED(const gchar *format, ...)
return NULL;
#else
va_start(args, format);
n = vasprintf(&ret, format, args);
n = g_vasprintf(&ret, format, args);
va_end(args);
if(n == -1) {