summaryrefslogtreecommitdiff
path: root/examples/libc/memory.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-01-08 05:05:02 -0800
committerBernard Xiong <[email protected]>2013-01-08 05:05:02 -0800
commit72782e920325808bbc58fc2344fc52033479b627 (patch)
tree45badbfa9818b8d1722463949beba0f88d1cbd9f /examples/libc/memory.c
parentb3cf278502e605fa03861a2da5685b4c8d72879e (diff)
convert end of line
Diffstat (limited to 'examples/libc/memory.c')
-rw-r--r--examples/libc/memory.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/examples/libc/memory.c b/examples/libc/memory.c
index 81b566f646..ee524fa43d 100644
--- a/examples/libc/memory.c
+++ b/examples/libc/memory.c
@@ -1,56 +1,56 @@
-/*
- * memory.c
- *
- * Created on: 2010-11-17
- * Author: bernard
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <finsh.h>
-#include <errno.h>
-
-static int errors = 0;
-static void merror(const char *msg)
-{
- ++errors;
- printf("Error: %s\n", msg);
-}
-
-int libc_mem(void)
-{
- void *p;
- int save;
-
- errno = 0;
-
- p = malloc(-1);
- save = errno;
-
- if (p != NULL)
- merror("malloc (-1) succeeded.");
-
- if (p == NULL && save != ENOMEM)
- merror("errno is not set correctly");
-
- p = malloc(10);
- if (p == NULL)
- merror("malloc (10) failed.");
-
- /* realloc (p, 0) == free (p). */
- p = realloc(p, 0);
- if (p != NULL)
- merror("realloc (p, 0) failed.");
-
- p = malloc(0);
- if (p == NULL)
- {
- printf("malloc(0) returns NULL\n");
- }
-
- p = realloc(p, 0);
- if (p != NULL)
- merror("realloc (p, 0) failed.");
-
- return errors != 0;
-}
-FINSH_FUNCTION_EXPORT(libc_mem, memory test for libc);
+/*
+ * memory.c
+ *
+ * Created on: 2010-11-17
+ * Author: bernard
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <finsh.h>
+#include <errno.h>
+
+static int errors = 0;
+static void merror(const char *msg)
+{
+ ++errors;
+ printf("Error: %s\n", msg);
+}
+
+int libc_mem(void)
+{
+ void *p;
+ int save;
+
+ errno = 0;
+
+ p = malloc(-1);
+ save = errno;
+
+ if (p != NULL)
+ merror("malloc (-1) succeeded.");
+
+ if (p == NULL && save != ENOMEM)
+ merror("errno is not set correctly");
+
+ p = malloc(10);
+ if (p == NULL)
+ merror("malloc (10) failed.");
+
+ /* realloc (p, 0) == free (p). */
+ p = realloc(p, 0);
+ if (p != NULL)
+ merror("realloc (p, 0) failed.");
+
+ p = malloc(0);
+ if (p == NULL)
+ {
+ printf("malloc(0) returns NULL\n");
+ }
+
+ p = realloc(p, 0);
+ if (p != NULL)
+ merror("realloc (p, 0) failed.");
+
+ return errors != 0;
+}
+FINSH_FUNCTION_EXPORT(libc_mem, memory test for libc);