From 08af426f01cf0321719c937d29a1d9315a0feab8 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sun, 7 Mar 2021 08:34:04 +0800 Subject: [example] 格式化整理 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/libc/memory.c | 54 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'examples/libc/memory.c') diff --git a/examples/libc/memory.c b/examples/libc/memory.c index ee524fa43d..d4f8e8dbde 100644 --- a/examples/libc/memory.c +++ b/examples/libc/memory.c @@ -12,45 +12,45 @@ static int errors = 0; static void merror(const char *msg) { - ++errors; - printf("Error: %s\n", msg); + ++errors; + printf("Error: %s\n", msg); } int libc_mem(void) { - void *p; - int save; + void *p; + int save; - errno = 0; + errno = 0; - p = malloc(-1); - save = errno; + p = malloc(-1); + save = errno; - if (p != NULL) - merror("malloc (-1) succeeded."); + if (p != NULL) + merror("malloc (-1) succeeded."); - if (p == NULL && save != ENOMEM) - merror("errno is not set correctly"); + if (p == NULL && save != ENOMEM) + merror("errno is not set correctly"); - p = malloc(10); - if (p == NULL) - merror("malloc (10) failed."); + 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."); + /* 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 = malloc(0); + if (p == NULL) + { + printf("malloc(0) returns NULL\n"); + } - p = realloc(p, 0); - if (p != NULL) - merror("realloc (p, 0) failed."); + p = realloc(p, 0); + if (p != NULL) + merror("realloc (p, 0) failed."); - return errors != 0; + return errors != 0; } FINSH_FUNCTION_EXPORT(libc_mem, memory test for libc); -- cgit v1.3.1