int main () { printf ("Initially: 0x%08lX 0x%08lX 0x%08lX\n", get_rusage_data_via_setrlimit (), get_rusage_data_via_iterator (), get_rusage_data ()); malloc (0x88); printf ("After small malloc: 0x%08lX 0x%08lX 0x%08lX\n", get_rusage_data_via_setrlimit (), get_rusage_data_via_iterator (), get_rusage_data ()); malloc (0x8812); printf ("After medium malloc: 0x%08lX 0x%08lX 0x%08lX\n", get_rusage_data_via_setrlimit (), get_rusage_data_via_iterator (), get_rusage_data ()); malloc (0x281237); printf ("After large malloc: 0x%08lX 0x%08lX 0x%08lX\n", get_rusage_data_via_setrlimit (), get_rusage_data_via_iterator (), get_rusage_data ()); return 0; }
int main () { uintptr_t value1, value2, value3; value1 = get_rusage_data (); memchunk1 = malloc (0x88); value2 = get_rusage_data (); memchunk2 = malloc (0x281237); value3 = get_rusage_data (); if (value1 == 0 && value2 == 0 && value3 == 0) { fprintf (stderr, "Skipping test: no way to determine data segment size\n"); return 77; } else { /* The data segment size is positive, except possibly at the beginning. */ ASSERT (value2 > 0); /* Allocating memory should not decrease the data segment size. */ ASSERT (value2 >= value1); ASSERT (value3 >= value2); #if !((defined __APPLE__ && defined __MACH__) || defined __OpenBSD__ || (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__) /* Allocating 2.5 MB of memory should increase the data segment size. */ ASSERT (value3 > value1); #endif return 0; } }