mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
alloca and vasprintf go away
This commit is contained in:
parent
3afce8ea0a
commit
b4c62873da
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
1999-01-11 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* gstrfuncs.c:
|
||||||
|
Do not use vasprintf.
|
||||||
|
|
||||||
|
* configure.in, glib.h, testglib.c, tests/.cvsignore,
|
||||||
|
tests/Makefile.am, tests/alloca-test.c:
|
||||||
|
Do not use alloca.
|
||||||
|
|
||||||
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
1999-01-11 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
* configure.in: Test for localtime_r only after including the
|
* configure.in: Test for localtime_r only after including the
|
||||||
|
49
configure.in
49
configure.in
@ -168,12 +168,6 @@ AC_HEADER_STDC
|
|||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_FUNC_ALLOCA
|
|
||||||
if test "x$ac_cv_func_alloca_works" = xyes; then
|
|
||||||
glib_have_alloca=yes
|
|
||||||
else
|
|
||||||
glib_have_alloca=no
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CHECK_FUNCS(atexit on_exit)
|
AC_CHECK_FUNCS(atexit on_exit)
|
||||||
|
|
||||||
@ -251,10 +245,9 @@ AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
|
|||||||
AC_CHECK_HEADERS(sys/times.h, AC_DEFINE(HAVE_SYS_TIMES_H))
|
AC_CHECK_HEADERS(sys/times.h, AC_DEFINE(HAVE_SYS_TIMES_H))
|
||||||
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
|
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
|
||||||
AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
|
AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
|
||||||
AC_CHECK_HEADER(alloca.h, glib_have_alloca_h=yes, glib_have_alloca_h=no)
|
|
||||||
|
|
||||||
# Check for some functions
|
# Check for some functions
|
||||||
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf vasprintf strcasecmp strncasecmp poll)
|
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll)
|
||||||
|
|
||||||
# Check for sys_errlist
|
# Check for sys_errlist
|
||||||
AC_MSG_CHECKING(for sys_errlist)
|
AC_MSG_CHECKING(for sys_errlist)
|
||||||
@ -870,7 +863,6 @@ _______EOF
|
|||||||
cat >>$outfile <<_______EOF
|
cat >>$outfile <<_______EOF
|
||||||
$glib_atexit
|
$glib_atexit
|
||||||
$glib_memmove
|
$glib_memmove
|
||||||
$glib_alloca
|
|
||||||
$glib_defines
|
$glib_defines
|
||||||
|
|
||||||
$glib_vacopy
|
$glib_vacopy
|
||||||
@ -1136,45 +1128,6 @@ if test x$glib_working_wctype = xno; then
|
|||||||
#define G_HAVE_BROKEN_WCTYPE 1"
|
#define G_HAVE_BROKEN_WCTYPE 1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$glib_have_alloca = xyes; then
|
|
||||||
glib_alloca="
|
|
||||||
|
|
||||||
/* alloca support */"
|
|
||||||
|
|
||||||
if test x$glib_have_alloca_h = xyes; then
|
|
||||||
glib_alloca="\$glib_alloca
|
|
||||||
#define G_HAVE_ALLOCA_H 1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
glib_alloca="\$glib_alloca
|
|
||||||
#define G_HAVE_ALLOCA 1
|
|
||||||
|
|
||||||
/* BEGIN autoconf 2.13 alloca incantation
|
|
||||||
NOTE: Do not un-indent the #pragma below. */
|
|
||||||
/* AIX requires this to be the first thing in the file. */
|
|
||||||
#ifdef __GNUC__
|
|
||||||
# ifndef alloca
|
|
||||||
# define alloca __builtin_alloca
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# if G_HAVE_ALLOCA_H
|
|
||||||
# include <alloca.h>
|
|
||||||
# else
|
|
||||||
# ifdef _AIX
|
|
||||||
#pragma alloca
|
|
||||||
# else
|
|
||||||
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
|
||||||
char *alloca ();
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
/* END autoconf 2.13 alloca incantation */
|
|
||||||
|
|
||||||
|
|
||||||
"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case x$enable_threads in
|
case x$enable_threads in
|
||||||
xyes) g_enable_threads_def="#define";;
|
xyes) g_enable_threads_def="#define";;
|
||||||
*) g_enable_threads_def="#undef ";;
|
*) g_enable_threads_def="#undef ";;
|
||||||
|
75
glib.h
75
glib.h
@ -301,16 +301,6 @@ extern "C" {
|
|||||||
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
|
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
|
||||||
#endif /* __DMALLOC_H__ */
|
#endif /* __DMALLOC_H__ */
|
||||||
|
|
||||||
/* alloca-based counterparts of the above routines */
|
|
||||||
#if G_HAVE_ALLOCA
|
|
||||||
# define g_alloca alloca
|
|
||||||
# define g_new_a(type, count) \
|
|
||||||
((type *) alloca ((unsigned) sizeof (type) * (count)))
|
|
||||||
# define g_new0_a(type, count) \
|
|
||||||
((type *) memset (alloca ((unsigned) sizeof (type) * (count)), 0, \
|
|
||||||
((unsigned) sizeof (type) * (count))))
|
|
||||||
#endif /* G_HAVE_ALLOCA */
|
|
||||||
|
|
||||||
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
|
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
|
||||||
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
|
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
|
||||||
sizeof (type), \
|
sizeof (type), \
|
||||||
@ -1465,71 +1455,6 @@ gchar* g_strescape (gchar *string);
|
|||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
|
||||||
/* Macros for dynamic strings via fast stack allocation
|
|
||||||
* All macros take a special first argument: the target gchar* string
|
|
||||||
*/
|
|
||||||
#if G_HAVE_ALLOCA
|
|
||||||
# define g_strdup_a(newstr,str) G_STMT_START { \
|
|
||||||
gchar *__new; \
|
|
||||||
const gchar *__old = (str); \
|
|
||||||
if (__old) \
|
|
||||||
{ \
|
|
||||||
size_t __len = strlen (__old) + 1; \
|
|
||||||
__new = alloca (__len); \
|
|
||||||
memcpy (__new, __old, __len); \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
__new = NULL; \
|
|
||||||
(newstr) = __new; \
|
|
||||||
} G_STMT_END
|
|
||||||
# define g_strndup_a(newstr,str,n) G_STMT_START { \
|
|
||||||
gchar *__new; \
|
|
||||||
const gchar *__old = (str); \
|
|
||||||
if (__old) \
|
|
||||||
{ \
|
|
||||||
guint __n = (n); \
|
|
||||||
size_t __len = strlen (__old); \
|
|
||||||
if (__len > (__n)) \
|
|
||||||
__len = (__n); \
|
|
||||||
__new = alloca (__len + 1); \
|
|
||||||
memcpy (__new, __old, __len); \
|
|
||||||
__new[__len] = 0; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
__new = NULL; \
|
|
||||||
(newstr) = __new; \
|
|
||||||
} G_STMT_END
|
|
||||||
# define g_strconcat3_a(newstr,str1,str2,str3) G_STMT_START { \
|
|
||||||
const gchar *__str1 = (str1); \
|
|
||||||
const gchar *__str2 = (str2); \
|
|
||||||
const gchar *__str3 = (str3); \
|
|
||||||
gchar *__new; \
|
|
||||||
if (__str1) { \
|
|
||||||
size_t __len1 = strlen (__str1); \
|
|
||||||
if (__str2) { \
|
|
||||||
size_t __len2 = strlen (__str2); \
|
|
||||||
if (__str3) { \
|
|
||||||
size_t __len3 = strlen (__str3); \
|
|
||||||
__new = alloca (__len1 + __len2 + __len3 + 1); \
|
|
||||||
__new[__len1 + __len2 + __len3] = 0; \
|
|
||||||
memcpy (__new + __len1 + __len2, __str3, __len3); \
|
|
||||||
} else { \
|
|
||||||
__new = alloca (__len1 + __len2 + 1); \
|
|
||||||
__new[__len1 + __len2] = 0; \
|
|
||||||
} \
|
|
||||||
memcpy (__new + __len1, __str2, __len2); \
|
|
||||||
} else { \
|
|
||||||
__new = alloca (__len1 + 1); \
|
|
||||||
__new[__len1] = 0; \
|
|
||||||
} \
|
|
||||||
memcpy (__new, __str1, __len1); \
|
|
||||||
} else \
|
|
||||||
__new = NULL; \
|
|
||||||
(newstr) = __new; \
|
|
||||||
} G_STMT_END
|
|
||||||
#endif /* G_HAVE_ALLOCA */
|
|
||||||
|
|
||||||
|
|
||||||
/* NULL terminated string arrays.
|
/* NULL terminated string arrays.
|
||||||
* g_strsplit() splits up string into max_tokens tokens at delim and
|
* g_strsplit() splits up string into max_tokens tokens at delim and
|
||||||
* returns a newly allocated string array.
|
* returns a newly allocated string array.
|
||||||
|
75
glib/glib.h
75
glib/glib.h
@ -301,16 +301,6 @@ extern "C" {
|
|||||||
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
|
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
|
||||||
#endif /* __DMALLOC_H__ */
|
#endif /* __DMALLOC_H__ */
|
||||||
|
|
||||||
/* alloca-based counterparts of the above routines */
|
|
||||||
#if G_HAVE_ALLOCA
|
|
||||||
# define g_alloca alloca
|
|
||||||
# define g_new_a(type, count) \
|
|
||||||
((type *) alloca ((unsigned) sizeof (type) * (count)))
|
|
||||||
# define g_new0_a(type, count) \
|
|
||||||
((type *) memset (alloca ((unsigned) sizeof (type) * (count)), 0, \
|
|
||||||
((unsigned) sizeof (type) * (count))))
|
|
||||||
#endif /* G_HAVE_ALLOCA */
|
|
||||||
|
|
||||||
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
|
#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
|
||||||
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
|
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
|
||||||
sizeof (type), \
|
sizeof (type), \
|
||||||
@ -1465,71 +1455,6 @@ gchar* g_strescape (gchar *string);
|
|||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
|
||||||
/* Macros for dynamic strings via fast stack allocation
|
|
||||||
* All macros take a special first argument: the target gchar* string
|
|
||||||
*/
|
|
||||||
#if G_HAVE_ALLOCA
|
|
||||||
# define g_strdup_a(newstr,str) G_STMT_START { \
|
|
||||||
gchar *__new; \
|
|
||||||
const gchar *__old = (str); \
|
|
||||||
if (__old) \
|
|
||||||
{ \
|
|
||||||
size_t __len = strlen (__old) + 1; \
|
|
||||||
__new = alloca (__len); \
|
|
||||||
memcpy (__new, __old, __len); \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
__new = NULL; \
|
|
||||||
(newstr) = __new; \
|
|
||||||
} G_STMT_END
|
|
||||||
# define g_strndup_a(newstr,str,n) G_STMT_START { \
|
|
||||||
gchar *__new; \
|
|
||||||
const gchar *__old = (str); \
|
|
||||||
if (__old) \
|
|
||||||
{ \
|
|
||||||
guint __n = (n); \
|
|
||||||
size_t __len = strlen (__old); \
|
|
||||||
if (__len > (__n)) \
|
|
||||||
__len = (__n); \
|
|
||||||
__new = alloca (__len + 1); \
|
|
||||||
memcpy (__new, __old, __len); \
|
|
||||||
__new[__len] = 0; \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
__new = NULL; \
|
|
||||||
(newstr) = __new; \
|
|
||||||
} G_STMT_END
|
|
||||||
# define g_strconcat3_a(newstr,str1,str2,str3) G_STMT_START { \
|
|
||||||
const gchar *__str1 = (str1); \
|
|
||||||
const gchar *__str2 = (str2); \
|
|
||||||
const gchar *__str3 = (str3); \
|
|
||||||
gchar *__new; \
|
|
||||||
if (__str1) { \
|
|
||||||
size_t __len1 = strlen (__str1); \
|
|
||||||
if (__str2) { \
|
|
||||||
size_t __len2 = strlen (__str2); \
|
|
||||||
if (__str3) { \
|
|
||||||
size_t __len3 = strlen (__str3); \
|
|
||||||
__new = alloca (__len1 + __len2 + __len3 + 1); \
|
|
||||||
__new[__len1 + __len2 + __len3] = 0; \
|
|
||||||
memcpy (__new + __len1 + __len2, __str3, __len3); \
|
|
||||||
} else { \
|
|
||||||
__new = alloca (__len1 + __len2 + 1); \
|
|
||||||
__new[__len1 + __len2] = 0; \
|
|
||||||
} \
|
|
||||||
memcpy (__new + __len1, __str2, __len2); \
|
|
||||||
} else { \
|
|
||||||
__new = alloca (__len1 + 1); \
|
|
||||||
__new[__len1] = 0; \
|
|
||||||
} \
|
|
||||||
memcpy (__new, __str1, __len1); \
|
|
||||||
} else \
|
|
||||||
__new = NULL; \
|
|
||||||
(newstr) = __new; \
|
|
||||||
} G_STMT_END
|
|
||||||
#endif /* G_HAVE_ALLOCA */
|
|
||||||
|
|
||||||
|
|
||||||
/* NULL terminated string arrays.
|
/* NULL terminated string arrays.
|
||||||
* g_strsplit() splits up string into max_tokens tokens at delim and
|
* g_strsplit() splits up string into max_tokens tokens at delim and
|
||||||
* returns a newly allocated string array.
|
* returns a newly allocated string array.
|
||||||
|
@ -108,15 +108,6 @@ g_strdup_vprintf (const gchar *format,
|
|||||||
va_list args1)
|
va_list args1)
|
||||||
{
|
{
|
||||||
gchar *buffer;
|
gchar *buffer;
|
||||||
|
|
||||||
#if (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK)
|
|
||||||
/* if memory checking is disabled, that means we can call g_free() on
|
|
||||||
* memory obtained via malloc(). This allows us to use the
|
|
||||||
* glibc vasprintf() call where available.
|
|
||||||
*/
|
|
||||||
vasprintf (&buffer, format, args1);
|
|
||||||
#else
|
|
||||||
|
|
||||||
va_list args2;
|
va_list args2;
|
||||||
|
|
||||||
G_VA_COPY (args2, args1);
|
G_VA_COPY (args2, args1);
|
||||||
@ -126,8 +117,6 @@ g_strdup_vprintf (const gchar *format,
|
|||||||
vsprintf (buffer, format, args2);
|
vsprintf (buffer, format, args2);
|
||||||
va_end (args2);
|
va_end (args2);
|
||||||
|
|
||||||
#endif /* (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) */
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
gstrfuncs.c
11
gstrfuncs.c
@ -108,15 +108,6 @@ g_strdup_vprintf (const gchar *format,
|
|||||||
va_list args1)
|
va_list args1)
|
||||||
{
|
{
|
||||||
gchar *buffer;
|
gchar *buffer;
|
||||||
|
|
||||||
#if (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK)
|
|
||||||
/* if memory checking is disabled, that means we can call g_free() on
|
|
||||||
* memory obtained via malloc(). This allows us to use the
|
|
||||||
* glibc vasprintf() call where available.
|
|
||||||
*/
|
|
||||||
vasprintf (&buffer, format, args1);
|
|
||||||
#else
|
|
||||||
|
|
||||||
va_list args2;
|
va_list args2;
|
||||||
|
|
||||||
G_VA_COPY (args2, args1);
|
G_VA_COPY (args2, args1);
|
||||||
@ -126,8 +117,6 @@ g_strdup_vprintf (const gchar *format,
|
|||||||
vsprintf (buffer, format, args2);
|
vsprintf (buffer, format, args2);
|
||||||
va_end (args2);
|
va_end (args2);
|
||||||
|
|
||||||
#endif /* (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) */
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
testglib.c
52
testglib.c
@ -910,58 +910,6 @@ main (int argc,
|
|||||||
#endif
|
#endif
|
||||||
g_print ("ok\n");
|
g_print ("ok\n");
|
||||||
|
|
||||||
#ifdef G_HAVE_ALLOCA
|
|
||||||
g_print ("checking alloca()-based allocation routines...");
|
|
||||||
|
|
||||||
string = g_alloca(80);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
for (i = 0; i < 80; i++)
|
|
||||||
string[i] = 'x';
|
|
||||||
string[79] = 0;
|
|
||||||
g_assert(strlen(string) == 79);
|
|
||||||
|
|
||||||
gti = g_new_a(GlibTestInfo, 2);
|
|
||||||
string = g_alloca(2);
|
|
||||||
strcpy(string, "x");
|
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
for (j = 0; j < 40; j++)
|
|
||||||
gti[i].name[j] = 'x';
|
|
||||||
gti[i].name[39] = 0;
|
|
||||||
g_assert(strlen(gti[i].name) == 39);
|
|
||||||
gti[i].age = 42;
|
|
||||||
}
|
|
||||||
g_assert(strcmp(string, "x") == 0);
|
|
||||||
|
|
||||||
string = g_new0_a(char, 40);
|
|
||||||
for (i = 0; i < 39; i++)
|
|
||||||
string[i] = 'x';
|
|
||||||
g_assert(strlen(string) == 39);
|
|
||||||
|
|
||||||
g_print ("ok\n");
|
|
||||||
|
|
||||||
g_print ("checking alloca()-based string duplication routines...");
|
|
||||||
|
|
||||||
g_strdup_a(string, GLIB_TEST_STRING);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
|
|
||||||
g_strdup_a(string, NULL);
|
|
||||||
g_assert(string == NULL);
|
|
||||||
|
|
||||||
g_strndup_a(string, GLIB_TEST_STRING, 5);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strlen(string) == 5);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING_5) == 0);
|
|
||||||
g_strndup_a(string, NULL, 20);
|
|
||||||
g_assert(string == NULL);
|
|
||||||
|
|
||||||
g_strconcat3_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
|
|
||||||
GLIB_TEST_STRING) == 0);
|
|
||||||
|
|
||||||
g_print ("ok\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ stamp-gc-h
|
|||||||
testgdate
|
testgdate
|
||||||
testgdateparser
|
testgdateparser
|
||||||
glibconfig-sysdefs.h
|
glibconfig-sysdefs.h
|
||||||
alloca-test
|
|
||||||
hash-test
|
hash-test
|
||||||
list-test
|
list-test
|
||||||
node-test
|
node-test
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
INCLUDES = -I$(top_srcdir)
|
INCLUDES = -I$(top_srcdir)
|
||||||
|
|
||||||
TESTS = \
|
TESTS = \
|
||||||
alloca-test \
|
|
||||||
array-test \
|
array-test \
|
||||||
dirname-test \
|
dirname-test \
|
||||||
hash-test \
|
hash-test \
|
||||||
@ -16,7 +15,6 @@ TESTS = \
|
|||||||
|
|
||||||
noinst_PROGRAMS = $(TESTS)
|
noinst_PROGRAMS = $(TESTS)
|
||||||
|
|
||||||
alloca_test_LDADD = $(top_builddir)/libglib.la
|
|
||||||
array_test_LDADD = $(top_builddir)/libglib.la
|
array_test_LDADD = $(top_builddir)/libglib.la
|
||||||
dirname_test_LDADD = $(top_builddir)/libglib.la
|
dirname_test_LDADD = $(top_builddir)/libglib.la
|
||||||
hash_test_LDADD = $(top_builddir)/libglib.la
|
hash_test_LDADD = $(top_builddir)/libglib.la
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
/* GLIB - Library of useful routines for C programming
|
|
||||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#undef G_LOG_DOMAIN
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "../glib.h"
|
|
||||||
|
|
||||||
#define GLIB_TEST_STRING "el dorado "
|
|
||||||
#define GLIB_TEST_STRING_5 "el do"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
guint age;
|
|
||||||
gchar name[40];
|
|
||||||
} GlibTestInfo;
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc,
|
|
||||||
char *argv[])
|
|
||||||
{
|
|
||||||
gchar *string;
|
|
||||||
GlibTestInfo *gti;
|
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
string = g_alloca(80);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
for (i = 0; i < 80; i++)
|
|
||||||
string[i] = 'x';
|
|
||||||
string[79] = 0;
|
|
||||||
g_assert(strlen(string) == 79);
|
|
||||||
|
|
||||||
gti = g_new_a(GlibTestInfo, 2);
|
|
||||||
string = g_alloca(2);
|
|
||||||
strcpy(string, "x");
|
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
for (j = 0; j < 40; j++)
|
|
||||||
gti[i].name[j] = 'x';
|
|
||||||
gti[i].name[39] = 0;
|
|
||||||
g_assert(strlen(gti[i].name) == 39);
|
|
||||||
gti[i].age = 42;
|
|
||||||
}
|
|
||||||
g_assert(strcmp(string, "x") == 0);
|
|
||||||
|
|
||||||
string = g_new0_a(char, 40);
|
|
||||||
for (i = 0; i < 39; i++)
|
|
||||||
string[i] = 'x';
|
|
||||||
g_assert(strlen(string) == 39);
|
|
||||||
|
|
||||||
g_strdup_a(string, GLIB_TEST_STRING);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
|
|
||||||
g_strdup_a(string, NULL);
|
|
||||||
g_assert(string == NULL);
|
|
||||||
|
|
||||||
g_strndup_a(string, GLIB_TEST_STRING, 5);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strlen(string) == 5);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING_5) == 0);
|
|
||||||
g_strndup_a(string, NULL, 20);
|
|
||||||
g_assert(string == NULL);
|
|
||||||
|
|
||||||
g_strconcat3_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
|
|
||||||
GLIB_TEST_STRING) == 0);
|
|
||||||
g_strconcat3_a (string, "1", NULL, "2");
|
|
||||||
g_assert (strcmp (string, "1") == 0);
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -910,58 +910,6 @@ main (int argc,
|
|||||||
#endif
|
#endif
|
||||||
g_print ("ok\n");
|
g_print ("ok\n");
|
||||||
|
|
||||||
#ifdef G_HAVE_ALLOCA
|
|
||||||
g_print ("checking alloca()-based allocation routines...");
|
|
||||||
|
|
||||||
string = g_alloca(80);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
for (i = 0; i < 80; i++)
|
|
||||||
string[i] = 'x';
|
|
||||||
string[79] = 0;
|
|
||||||
g_assert(strlen(string) == 79);
|
|
||||||
|
|
||||||
gti = g_new_a(GlibTestInfo, 2);
|
|
||||||
string = g_alloca(2);
|
|
||||||
strcpy(string, "x");
|
|
||||||
for (i = 0; i < 2; i++) {
|
|
||||||
for (j = 0; j < 40; j++)
|
|
||||||
gti[i].name[j] = 'x';
|
|
||||||
gti[i].name[39] = 0;
|
|
||||||
g_assert(strlen(gti[i].name) == 39);
|
|
||||||
gti[i].age = 42;
|
|
||||||
}
|
|
||||||
g_assert(strcmp(string, "x") == 0);
|
|
||||||
|
|
||||||
string = g_new0_a(char, 40);
|
|
||||||
for (i = 0; i < 39; i++)
|
|
||||||
string[i] = 'x';
|
|
||||||
g_assert(strlen(string) == 39);
|
|
||||||
|
|
||||||
g_print ("ok\n");
|
|
||||||
|
|
||||||
g_print ("checking alloca()-based string duplication routines...");
|
|
||||||
|
|
||||||
g_strdup_a(string, GLIB_TEST_STRING);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
|
|
||||||
g_strdup_a(string, NULL);
|
|
||||||
g_assert(string == NULL);
|
|
||||||
|
|
||||||
g_strndup_a(string, GLIB_TEST_STRING, 5);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strlen(string) == 5);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING_5) == 0);
|
|
||||||
g_strndup_a(string, NULL, 20);
|
|
||||||
g_assert(string == NULL);
|
|
||||||
|
|
||||||
g_strconcat3_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
|
|
||||||
g_assert(string != NULL);
|
|
||||||
g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
|
|
||||||
GLIB_TEST_STRING) == 0);
|
|
||||||
|
|
||||||
g_print ("ok\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user