summaryrefslogtreecommitdiffstats
path: root/tests/lib/test_memory.c
diff options
context:
space:
mode:
authorwhitespace / reindent <invalid@invalid.invalid>2017-07-17 14:03:14 +0200
committerwhitespace / reindent <invalid@invalid.invalid>2017-07-17 14:04:07 +0200
commitd62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch)
tree3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /tests/lib/test_memory.c
parent*: add indent control files (diff)
downloadfrr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz
frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tests/lib/test_memory.c')
-rw-r--r--tests/lib/test_memory.c146
1 files changed, 71 insertions, 75 deletions
diff --git a/tests/lib/test_memory.c b/tests/lib/test_memory.c
index 633ee0d56..84be9cb76 100644
--- a/tests/lib/test_memory.c
+++ b/tests/lib/test_memory.c
@@ -1,4 +1,4 @@
-/*
+/*
* This file is part of Quagga.
*
* Quagga is free software; you can redistribute it and/or modify it
@@ -44,81 +44,77 @@ struct thread_master *master;
#define TIMES 10
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
{
- void *a[10];
- int i;
+ void *a[10];
+ int i;
- printf ("malloc x, malloc x, free, malloc x, free free\n\n");
- /* simple case, test cache */
- for (i = 0; i < TIMES; i++)
- {
- a[0] = XMALLOC (MTYPE_TEST, 1024);
- memset (a[0], 1, 1024);
- a[1] = XMALLOC (MTYPE_TEST, 1024);
- memset (a[1], 1, 1024);
- XFREE(MTYPE_TEST, a[0]); /* should go to cache */
- a[0] = XMALLOC (MTYPE_TEST, 1024); /* should be satisfied from cache */
- XFREE(MTYPE_TEST, a[0]);
- XFREE(MTYPE_TEST, a[1]);
- }
-
- printf ("malloc x, malloc y, free x, malloc y, free free\n\n");
- /* cache should go invalid, valid, invalid, etc.. */
- for (i = 0; i < TIMES; i++)
- {
- a[0] = XMALLOC (MTYPE_TEST, 512);
- memset (a[0], 1, 512);
- a[1] = XMALLOC (MTYPE_TEST, 1024); /* invalidate cache */
- memset (a[1], 1, 1024);
- XFREE(MTYPE_TEST, a[0]);
- a[0] = XMALLOC (MTYPE_TEST, 1024);
- XFREE(MTYPE_TEST, a[0]);
- XFREE(MTYPE_TEST, a[1]);
- /* cache should become valid again on next request */
- }
+ printf("malloc x, malloc x, free, malloc x, free free\n\n");
+ /* simple case, test cache */
+ for (i = 0; i < TIMES; i++) {
+ a[0] = XMALLOC(MTYPE_TEST, 1024);
+ memset(a[0], 1, 1024);
+ a[1] = XMALLOC(MTYPE_TEST, 1024);
+ memset(a[1], 1, 1024);
+ XFREE(MTYPE_TEST, a[0]); /* should go to cache */
+ a[0] = XMALLOC(MTYPE_TEST,
+ 1024); /* should be satisfied from cache */
+ XFREE(MTYPE_TEST, a[0]);
+ XFREE(MTYPE_TEST, a[1]);
+ }
- printf ("calloc\n\n");
- /* test calloc */
- for (i = 0; i < TIMES; i++)
- {
- a[0] = XCALLOC (MTYPE_TEST, 1024);
- memset (a[0], 1, 1024);
- a[1] = XCALLOC (MTYPE_TEST, 512); /* invalidate cache */
- memset (a[1], 1, 512);
- XFREE(MTYPE_TEST, a[1]);
- XFREE(MTYPE_TEST, a[0]);
- /* alloc == 0, cache can become valid again on next request */
- }
-
- printf ("calloc and realloc\n\n");
- /* check calloc + realloc */
- for (i = 0; i < TIMES; i++)
- {
- printf ("calloc a0 1024\n");
- a[0] = XCALLOC (MTYPE_TEST, 1024);
- memset (a[0], 1, 1024/2);
-
- printf ("calloc 1 1024\n");
- a[1] = XCALLOC (MTYPE_TEST, 1024);
- memset (a[1], 1, 1024/2);
-
- printf ("realloc 0 1024\n");
- a[3] = XREALLOC (MTYPE_TEST, a[0], 2048); /* invalidate cache */
- if (a[3] != NULL)
- a[0] = a[3];
- memset (a[0], 1, 1024);
-
- printf ("calloc 2 512\n");
- a[2] = XCALLOC (MTYPE_TEST, 512);
- memset (a[2], 1, 512);
-
- printf ("free 1 0 2\n");
- XFREE(MTYPE_TEST, a[1]);
- XFREE(MTYPE_TEST, a[0]);
- XFREE(MTYPE_TEST, a[2]);
- /* alloc == 0, cache valid next request */
- }
- return 0;
+ printf("malloc x, malloc y, free x, malloc y, free free\n\n");
+ /* cache should go invalid, valid, invalid, etc.. */
+ for (i = 0; i < TIMES; i++) {
+ a[0] = XMALLOC(MTYPE_TEST, 512);
+ memset(a[0], 1, 512);
+ a[1] = XMALLOC(MTYPE_TEST, 1024); /* invalidate cache */
+ memset(a[1], 1, 1024);
+ XFREE(MTYPE_TEST, a[0]);
+ a[0] = XMALLOC(MTYPE_TEST, 1024);
+ XFREE(MTYPE_TEST, a[0]);
+ XFREE(MTYPE_TEST, a[1]);
+ /* cache should become valid again on next request */
+ }
+
+ printf("calloc\n\n");
+ /* test calloc */
+ for (i = 0; i < TIMES; i++) {
+ a[0] = XCALLOC(MTYPE_TEST, 1024);
+ memset(a[0], 1, 1024);
+ a[1] = XCALLOC(MTYPE_TEST, 512); /* invalidate cache */
+ memset(a[1], 1, 512);
+ XFREE(MTYPE_TEST, a[1]);
+ XFREE(MTYPE_TEST, a[0]);
+ /* alloc == 0, cache can become valid again on next request */
+ }
+
+ printf("calloc and realloc\n\n");
+ /* check calloc + realloc */
+ for (i = 0; i < TIMES; i++) {
+ printf("calloc a0 1024\n");
+ a[0] = XCALLOC(MTYPE_TEST, 1024);
+ memset(a[0], 1, 1024 / 2);
+
+ printf("calloc 1 1024\n");
+ a[1] = XCALLOC(MTYPE_TEST, 1024);
+ memset(a[1], 1, 1024 / 2);
+
+ printf("realloc 0 1024\n");
+ a[3] = XREALLOC(MTYPE_TEST, a[0], 2048); /* invalidate cache */
+ if (a[3] != NULL)
+ a[0] = a[3];
+ memset(a[0], 1, 1024);
+
+ printf("calloc 2 512\n");
+ a[2] = XCALLOC(MTYPE_TEST, 512);
+ memset(a[2], 1, 512);
+
+ printf("free 1 0 2\n");
+ XFREE(MTYPE_TEST, a[1]);
+ XFREE(MTYPE_TEST, a[0]);
+ XFREE(MTYPE_TEST, a[2]);
+ /* alloc == 0, cache valid next request */
+ }
+ return 0;
}