Commit 26d64a85a32192b559364f241908fb24cda378e6

Authored by malc
1 parent a7d27b53

Format per CODING_STYLE

Signed-off-by: malc <av1474@comtv.ru>
Showing 1 changed file with 10 additions and 6 deletions
qemu-malloc.c
@@ -26,8 +26,9 @@ @@ -26,8 +26,9 @@
26 26
27 static void *oom_check(void *ptr) 27 static void *oom_check(void *ptr)
28 { 28 {
29 - if (ptr == NULL) 29 + if (ptr == NULL) {
30 abort(); 30 abort();
  31 + }
31 return ptr; 32 return ptr;
32 } 33 }
33 34
@@ -43,18 +44,20 @@ void qemu_free(void *ptr) @@ -43,18 +44,20 @@ void qemu_free(void *ptr)
43 44
44 void *qemu_malloc(size_t size) 45 void *qemu_malloc(size_t size)
45 { 46 {
46 - if (!size) 47 + if (!size) {
47 abort(); 48 abort();
  49 + }
48 return oom_check(malloc(size)); 50 return oom_check(malloc(size));
49 } 51 }
50 52
51 void *qemu_realloc(void *ptr, size_t size) 53 void *qemu_realloc(void *ptr, size_t size)
52 { 54 {
53 - if (size) 55 + if (size) {
54 return oom_check(realloc(ptr, size)); 56 return oom_check(realloc(ptr, size));
55 - else {  
56 - if (ptr) 57 + } else {
  58 + if (ptr) {
57 return realloc(ptr, size); 59 return realloc(ptr, size);
  60 + }
58 } 61 }
59 abort(); 62 abort();
60 } 63 }
@@ -81,8 +84,9 @@ char *qemu_strndup(const char *str, size_t size) @@ -81,8 +84,9 @@ char *qemu_strndup(const char *str, size_t size)
81 const char *end = memchr(str, 0, size); 84 const char *end = memchr(str, 0, size);
82 char *new; 85 char *new;
83 86
84 - if (end) 87 + if (end) {
85 size = end - str; 88 size = end - str;
  89 + }
86 90
87 new = qemu_malloc(size + 1); 91 new = qemu_malloc(size + 1);
88 new[size] = 0; 92 new[size] = 0;