| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/xmalloc.c | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | - | |||||||
| 9 | - | |||||||
| 10 | - | |||||||
| 11 | - | |||||||
| 12 | - | |||||||
| 13 | - | |||||||
| 14 | static void * lbreak; | - | ||||||
| 15 | static int brkfound; | - | ||||||
| 16 | static size_t allocated; | - | ||||||
| 17 | static size_t | - | ||||||
| 18 | findbrk () | - | ||||||
| 19 | { | - | ||||||
| 20 | do { if (brkfound == 0 
 never executed: } while (0); end of block | 0 | ||||||
| 21 | return never executed: (char *)sbrk (0) - (char *)lbreak; return (char *)sbrk (0) - (char *)lbreak;never executed:  return (char *)sbrk (0) - (char *)lbreak; | 0 | ||||||
| 22 | } | - | ||||||
| 23 | - | |||||||
| 24 | - | |||||||
| 25 | - | |||||||
| 26 | - | |||||||
| 27 | static void | - | ||||||
| 28 | allocerr (func, bytes) | - | ||||||
| 29 | const char *func; | - | ||||||
| 30 | size_t bytes; | - | ||||||
| 31 | { | - | ||||||
| 32 | - | |||||||
| 33 | allocated = findbrk (); | - | ||||||
| 34 | fatal_error ( | - | ||||||
| 35 | dcgettext (((void *)0), | - | ||||||
| 36 | "%s: cannot allocate %lu bytes (%lu bytes allocated)" | - | ||||||
| 37 | , 5) | - | ||||||
| 38 | , func, (unsigned long)bytes, (unsigned long)allocated); | - | ||||||
| 39 | - | |||||||
| 40 | - | |||||||
| 41 | - | |||||||
| 42 | } never executed:  end of block | 0 | ||||||
| 43 | - | |||||||
| 44 | - | |||||||
| 45 | - | |||||||
| 46 | - | |||||||
| 47 | void * | - | ||||||
| 48 | xmalloc (bytes) | - | ||||||
| 49 | size_t bytes; | - | ||||||
| 50 | { | - | ||||||
| 51 | void * temp; | - | ||||||
| 52 | - | |||||||
| 53 | - | |||||||
| 54 | if (bytes == 0 
 | 0-2424 | ||||||
| 55 | internal_warning("xmalloc: size argument is 0"); never executed:  internal_warning("xmalloc: size argument is 0"); | 0 | ||||||
| 56 | - | |||||||
| 57 | - | |||||||
| 58 | do { if (brkfound == 0 
 never executed: } while (0); end of block | 0-2424 | ||||||
| 59 | temp = malloc (bytes); | - | ||||||
| 60 | - | |||||||
| 61 | if (temp == 0 
 | 0-2424 | ||||||
| 62 | allocerr ("xmalloc", bytes); never executed:  allocerr ("xmalloc", bytes); | 0 | ||||||
| 63 | - | |||||||
| 64 | return executed 2424 times by 1 test: (temp); return (temp);Executed by: 
 executed 2424 times by 1 test:  return (temp);Executed by: 
 | 2424 | ||||||
| 65 | } | - | ||||||
| 66 | - | |||||||
| 67 | void * | - | ||||||
| 68 | xrealloc (pointer, bytes) | - | ||||||
| 69 | void * pointer; | - | ||||||
| 70 | size_t bytes; | - | ||||||
| 71 | { | - | ||||||
| 72 | void * temp; | - | ||||||
| 73 | - | |||||||
| 74 | - | |||||||
| 75 | if (bytes == 0 
 | 0-42 | ||||||
| 76 | internal_warning("xrealloc: size argument is 0"); never executed:  internal_warning("xrealloc: size argument is 0"); | 0 | ||||||
| 77 | - | |||||||
| 78 | - | |||||||
| 79 | do { if (brkfound == 0 
 never executed: } while (0); end of block | 0-42 | ||||||
| 80 | temp = pointer 
 | 11-31 | ||||||
| 81 | - | |||||||
| 82 | if (temp == 0 
 | 0-42 | ||||||
| 83 | allocerr ("xrealloc", bytes); never executed:  allocerr ("xrealloc", bytes); | 0 | ||||||
| 84 | - | |||||||
| 85 | return executed 42 times by 1 test: (temp); return (temp);Executed by: 
 executed 42 times by 1 test:  return (temp);Executed by: 
 | 42 | ||||||
| 86 | } | - | ||||||
| 87 | - | |||||||
| 88 | - | |||||||
| 89 | - | |||||||
| 90 | void | - | ||||||
| 91 | xfree (string) | - | ||||||
| 92 | void * string; | - | ||||||
| 93 | { | - | ||||||
| 94 | if (string 
 | 6254-23833 | ||||||
| 95 | free (string); executed 23833 times by 1 test:  free (string);Executed by: 
 | 23833 | ||||||
| 96 | } executed 30087 times by 1 test:  end of blockExecuted by: 
 | 30087 | ||||||
| 97 | - | |||||||
| 98 | - | |||||||
| 99 | - | |||||||
| 100 | static void | - | ||||||
| 101 | sh_allocerr (func, bytes, file, line) | - | ||||||
| 102 | const char *func; | - | ||||||
| 103 | size_t bytes; | - | ||||||
| 104 | char *file; | - | ||||||
| 105 | int line; | - | ||||||
| 106 | { | - | ||||||
| 107 | - | |||||||
| 108 | allocated = findbrk (); | - | ||||||
| 109 | fatal_error ( | - | ||||||
| 110 | dcgettext (((void *)0), | - | ||||||
| 111 | "%s: %s:%d: cannot allocate %lu bytes (%lu bytes allocated)" | - | ||||||
| 112 | , 5) | - | ||||||
| 113 | , func, file, line, (unsigned long)bytes, (unsigned long)allocated); | - | ||||||
| 114 | - | |||||||
| 115 | - | |||||||
| 116 | - | |||||||
| 117 | } never executed:  end of block | 0 | ||||||
| 118 | - | |||||||
| 119 | void * | - | ||||||
| 120 | sh_xmalloc (bytes, file, line) | - | ||||||
| 121 | size_t bytes; | - | ||||||
| 122 | char *file; | - | ||||||
| 123 | int line; | - | ||||||
| 124 | { | - | ||||||
| 125 | void * temp; | - | ||||||
| 126 | - | |||||||
| 127 | - | |||||||
| 128 | if (bytes == 0 
 | 0-Inf | ||||||
| 129 | internal_warning("xmalloc: %s:%d: size argument is 0", file, line); never executed:  internal_warning("xmalloc: %s:%d: size argument is 0", file, line); | 0 | ||||||
| 130 | - | |||||||
| 131 | - | |||||||
| 132 | do { if (brkfound == 0 
 executed 5432 times by 1 test: } while (0); end of blockExecuted by: 
 | 5432-Inf | ||||||
| 133 | temp = sh_malloc (bytes, file, line); | - | ||||||
| 134 | - | |||||||
| 135 | if (temp == 0 
 | 0-Inf | ||||||
| 136 | sh_allocerr ("xmalloc", bytes, file, line); never executed:  sh_allocerr ("xmalloc", bytes, file, line); | 0 | ||||||
| 137 | - | |||||||
| 138 | return executed 2147483647 times by 1 test: (temp); return (temp);Executed by: 
 executed 2147483647 times by 1 test:  return (temp);Executed by: 
 | Inf | ||||||
| 139 | } | - | ||||||
| 140 | - | |||||||
| 141 | void * | - | ||||||
| 142 | sh_xrealloc (pointer, bytes, file, line) | - | ||||||
| 143 | void * pointer; | - | ||||||
| 144 | size_t bytes; | - | ||||||
| 145 | char *file; | - | ||||||
| 146 | int line; | - | ||||||
| 147 | { | - | ||||||
| 148 | void * temp; | - | ||||||
| 149 | - | |||||||
| 150 | - | |||||||
| 151 | if (bytes == 0 
 | 0-4814432 | ||||||
| 152 | internal_warning("xrealloc: %s:%d: size argument is 0", file, line); never executed:  internal_warning("xrealloc: %s:%d: size argument is 0", file, line); | 0 | ||||||
| 153 | - | |||||||
| 154 | - | |||||||
| 155 | do { if (brkfound == 0 
 never executed: } while (0); end of block | 0-4814432 | ||||||
| 156 | temp = pointer 
 | 92882-4721550 | ||||||
| 157 | - | |||||||
| 158 | if (temp == 0 
 | 0-4814432 | ||||||
| 159 | sh_allocerr ("xrealloc", bytes, file, line); never executed:  sh_allocerr ("xrealloc", bytes, file, line); | 0 | ||||||
| 160 | - | |||||||
| 161 | return executed 4814432 times by 1 test: (temp); return (temp);Executed by: 
 executed 4814432 times by 1 test:  return (temp);Executed by: 
 | 4814432 | ||||||
| 162 | } | - | ||||||
| 163 | - | |||||||
| 164 | void | - | ||||||
| 165 | sh_xfree (string, file, line) | - | ||||||
| 166 | void * string; | - | ||||||
| 167 | char *file; | - | ||||||
| 168 | int line; | - | ||||||
| 169 | { | - | ||||||
| 170 | if (string 
 | 365685933-Inf | ||||||
| 171 | sh_free (string, file, line); executed 2147483647 times by 1 test:  sh_free (string, file, line);Executed by: 
 | Inf | ||||||
| 172 | } executed 2147483647 times by 1 test:  end of blockExecuted by: 
 | Inf | ||||||
| Switch to Source code | Preprocessed file |