OpenCoverage

xmalloc.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/xmalloc.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14static void * lbreak;-
15static int brkfound;-
16static size_t allocated;-
17static size_t-
18findbrk ()-
19{-
20 do { if (brkfound == 0
brkfound == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { lbreak = (void *)sbrk (0); brkfound++; }
never executed: end of block
} while (0);
0
21 return
never executed: return (char *)sbrk (0) - (char *)lbreak;
(char *)sbrk (0) - (char *)lbreak;
never executed: return (char *)sbrk (0) - (char *)lbreak;
0
22}-
23-
24-
25-
26-
27static void-
28allocerr (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-
47void *-
48xmalloc (bytes)-
49 size_t bytes;-
50{-
51 void * temp;-
52-
53-
54 if (bytes == 0
bytes == 0Description
TRUEnever evaluated
FALSEevaluated 2424 times by 1 test
Evaluated by:
  • Self test
)
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
brkfound == 0Description
TRUEnever evaluated
FALSEevaluated 2424 times by 1 test
Evaluated by:
  • Self test
) { lbreak = (void *)sbrk (0); brkfound++; }
never executed: end of block
} while (0);
0-2424
59 temp = malloc (bytes);-
60-
61 if (temp == 0
temp == 0Description
TRUEnever evaluated
FALSEevaluated 2424 times by 1 test
Evaluated by:
  • Self test
)
0-2424
62 allocerr ("xmalloc", bytes);
never executed: allocerr ("xmalloc", bytes);
0
63-
64 return
executed 2424 times by 1 test: return (temp);
Executed by:
  • Self test
(temp);
executed 2424 times by 1 test: return (temp);
Executed by:
  • Self test
2424
65}-
66-
67void *-
68xrealloc (pointer, bytes)-
69 void * pointer;-
70 size_t bytes;-
71{-
72 void * temp;-
73-
74-
75 if (bytes == 0
bytes == 0Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
)
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
brkfound == 0Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
) { lbreak = (void *)sbrk (0); brkfound++; }
never executed: end of block
} while (0);
0-42
80 temp = pointer
pointerDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
? realloc (pointer, bytes) : malloc (bytes);
11-31
81-
82 if (temp == 0
temp == 0Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
)
0-42
83 allocerr ("xrealloc", bytes);
never executed: allocerr ("xrealloc", bytes);
0
84-
85 return
executed 42 times by 1 test: return (temp);
Executed by:
  • Self test
(temp);
executed 42 times by 1 test: return (temp);
Executed by:
  • Self test
42
86}-
87-
88-
89-
90void-
91xfree (string)-
92 void * string;-
93{-
94 if (string
stringDescription
TRUEevaluated 23833 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6254 times by 1 test
Evaluated by:
  • Self test
)
6254-23833
95 free (string);
executed 23833 times by 1 test: free (string);
Executed by:
  • Self test
23833
96}
executed 30087 times by 1 test: end of block
Executed by:
  • Self test
30087
97-
98-
99-
100static void-
101sh_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-
119void *-
120sh_xmalloc (bytes, file, line)-
121 size_t bytes;-
122 char *file;-
123 int line;-
124{-
125 void * temp;-
126-
127-
128 if (bytes == 0
bytes == 0Description
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
)
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
brkfound == 0Description
TRUEevaluated 5432 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
) { lbreak = (void *)sbrk (0); brkfound++; }
executed 5432 times by 1 test: end of block
Executed by:
  • Self test
} while (0);
5432-Inf
133 temp = sh_malloc (bytes, file, line);-
134-
135 if (temp == 0
temp == 0Description
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
)
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: return (temp);
Executed by:
  • Self test
(temp);
executed 2147483647 times by 1 test: return (temp);
Executed by:
  • Self test
Inf
139}-
140-
141void *-
142sh_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
bytes == 0Description
TRUEnever evaluated
FALSEevaluated 4814432 times by 1 test
Evaluated by:
  • Self test
)
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
brkfound == 0Description
TRUEnever evaluated
FALSEevaluated 4814432 times by 1 test
Evaluated by:
  • Self test
) { lbreak = (void *)sbrk (0); brkfound++; }
never executed: end of block
} while (0);
0-4814432
156 temp = pointer
pointerDescription
TRUEevaluated 92882 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4721550 times by 1 test
Evaluated by:
  • Self test
? sh_realloc (pointer, bytes, file, line) : sh_malloc (bytes, file, line);
92882-4721550
157-
158 if (temp == 0
temp == 0Description
TRUEnever evaluated
FALSEevaluated 4814432 times by 1 test
Evaluated by:
  • Self test
)
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: return (temp);
Executed by:
  • Self test
(temp);
executed 4814432 times by 1 test: return (temp);
Executed by:
  • Self test
4814432
162}-
163-
164void-
165sh_xfree (string, file, line)-
166 void * string;-
167 char *file;-
168 int line;-
169{-
170 if (string
stringDescription
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 365685933 times by 1 test
Evaluated by:
  • Self test
)
365685933-Inf
171 sh_free (string, file, line);
executed 2147483647 times by 1 test: sh_free (string, file, line);
Executed by:
  • Self test
Inf
172}
executed 2147483647 times by 1 test: end of block
Executed by:
  • Self test
Inf
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2