+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
+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>
* configure.in: Test for localtime_r only after including the
# Checks for library functions.
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_HEADERS(sys/times.h, AC_DEFINE(HAVE_SYS_TIMES_H))
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_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
-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
AC_MSG_CHECKING(for sys_errlist)
cat >>$outfile <<_______EOF
$glib_atexit
$glib_memmove
-$glib_alloca
$glib_defines
$glib_vacopy
#define G_HAVE_BROKEN_WCTYPE 1"
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
xyes) g_enable_threads_def="#define";;
*) g_enable_threads_def="#undef ";;
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
#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) ( \
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
sizeof (type), \
gpointer g_memdup (gconstpointer mem,
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.
* g_strsplit() splits up string into max_tokens tokens at delim and
* returns a newly allocated string array.
((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
#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) ( \
g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
sizeof (type), \
gpointer g_memdup (gconstpointer mem,
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.
* g_strsplit() splits up string into max_tokens tokens at delim and
* returns a newly allocated string array.
va_list args1)
{
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;
G_VA_COPY (args2, args1);
vsprintf (buffer, format, args2);
va_end (args2);
-#endif /* (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) */
-
return buffer;
}
va_list args1)
{
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;
G_VA_COPY (args2, args1);
vsprintf (buffer, format, args2);
va_end (args2);
-#endif /* (HAVE_VASPRINTF) && !(ENABLE_MEM_CHECK) */
-
return buffer;
}
#endif
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;
}
testgdate
testgdateparser
glibconfig-sysdefs.h
-alloca-test
hash-test
list-test
node-test
INCLUDES = -I$(top_srcdir)
TESTS = \
- alloca-test \
array-test \
dirname-test \
hash-test \
noinst_PROGRAMS = $(TESTS)
-alloca_test_LDADD = $(top_builddir)/libglib.la
array_test_LDADD = $(top_builddir)/libglib.la
dirname_test_LDADD = $(top_builddir)/libglib.la
hash_test_LDADD = $(top_builddir)/libglib.la
+++ /dev/null
-/* 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;
-}
-
#endif
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;
}