Re: glib: alloca brain damages
- From: Jeff Garzik <jgarzik pobox com>
- To: gtk-devel-list redhat com
- Subject: Re: glib: alloca brain damages
- Date: Fri, 08 Jan 1999 21:07:20 -0500
Ok, here is a corrected test, which also works fine on x86 and alpha.
Jeff
/* a-better-test-of-the-real-problem.c */
#include <string.h>
#include <glib.h>
#define TEST_STR "papa wons haz gud fud"
#define TEST_STR_2 "%d soup is gud fud %d"
#define NUM_RECURSIONS 99
#define TEST_STR_LEN 30
void do_recurse (int recno)
{
char *s, s1[TEST_STR_LEN], s2[TEST_STR_LEN];
int i;
if (recno < 1)
return;
i = sprintf(s1, TEST_STR_2, recno, recno * 42);
g_assert(i > 0);
s = g_new0_a(char, TEST_STR_LEN);
g_assert(s != NULL);
i = sprintf(s, TEST_STR_2, recno, recno * 42);
g_assert(i > 0);
g_assert(strcmp(s, s1) == 0);
do_recurse(recno - 1);
i = sprintf(s2, TEST_STR_2, recno, recno * 42);
g_assert(i > 0);
g_assert(strcmp(s1, s2) == 0);
g_assert(strcmp(s, s2) == 0);
}
int main()
{
do_recurse(NUM_RECURSIONS);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]