OpenCoverage

obstack.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/lib/obstack.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2static void *-
3call_chunkfun (struct obstack *h, size_t size)-
4{-
5 if (h->use_extra_arg
h->use_extra_argDescription
TRUEnever evaluated
FALSEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
)
0-79
6 return
never executed: return h->chunkfun.extra (h->extra_arg, size);
h->chunkfun.extra (h->extra_arg, size);
never executed: return h->chunkfun.extra (h->extra_arg, size);
0
7 else-
8 return
executed 79 times by 4 tests: return h->chunkfun.plain (size);
Executed by:
  • dircolors
  • ls
  • sort
  • wc
h->chunkfun.plain (size);
executed 79 times by 4 tests: return h->chunkfun.plain (size);
Executed by:
  • dircolors
  • ls
  • sort
  • wc
79
9}-
10-
11static void-
12call_freefun (struct obstack *h, void *old_chunk)-
13{-
14 if (h->use_extra_arg
h->use_extra_argDescription
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • wc
)
0-33
15 h->freefun.extra (h->extra_arg, old_chunk);
never executed: h->freefun.extra (h->extra_arg, old_chunk);
0
16 else-
17 h->freefun.plain (old_chunk);
executed 33 times by 1 test: h->freefun.plain (old_chunk);
Executed by:
  • wc
33
18}-
19static int-
20_obstack_begin_worker (struct obstack *h,-
21 size_t size, size_t alignment)-
22{-
23 struct _obstack_chunk *chunk;-
24-
25 if (alignment == 0
alignment == 0Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
)
0-79
26 alignment = ((
(__alignof__ (...__ (void *))))Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
__alignof__ (long double)) > (((__alignof__ (uintmax_t)) > (__alignof__ (void *)) ? (__alignof__ (uintmax_t)) : (__alignof__ (void *))))
(__alignof__ (...__ (void *))))Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
? (__alignof__ (long double)) : (((
(__alignof__ (...of__ (void *))Description
TRUEnever evaluated
FALSEnever evaluated
__alignof__ (uintmax_t)) > (__alignof__ (void *))
(__alignof__ (...of__ (void *))Description
TRUEnever evaluated
FALSEnever evaluated
? (__alignof__ (uintmax_t)) : (__alignof__ (void *)))));
executed 79 times by 4 tests: alignment = ((__alignof__ (long double)) > (((__alignof__ (uintmax_t)) > (__alignof__ (void *)) ? (__alignof__ (uintmax_t)) : (__alignof__ (void *)))) ? (__alignof__ (long double)) : (((__alignof__ (uintmax_t)) > (__alignof__ (void *)) ? (__alignof__ (uintmax_t)) : (__alignof__ (void *)))));
Executed by:
  • dircolors
  • ls
  • sort
  • wc
0-79
27 if (size == 0
size == 0Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
)
0-79
28-
29 {-
30 int extra = ((((12 + ((
(sizeof (long ...of (void *))))Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
sizeof (long double)) > (((sizeof (uintmax_t)) > (sizeof (void *)) ? (sizeof (uintmax_t)) : (sizeof (void *))))
(sizeof (long ...of (void *))))Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
? (sizeof (long double)) : (((
(sizeof (uintm...zeof (void *))Description
TRUEnever evaluated
FALSEnever evaluated
sizeof (uintmax_t)) > (sizeof (void *))
(sizeof (uintm...zeof (void *))Description
TRUEnever evaluated
FALSEnever evaluated
? (sizeof (uintmax_t)) : (sizeof (void *))))) - 1) & ~(((sizeof (long double)) > (((sizeof (uintmax_t)) > (sizeof (void *)) ? (sizeof (uintmax_t)) : (sizeof (void *)))) ? (sizeof (long double)) : (((sizeof (uintmax_t)) > (sizeof (void *)) ? (sizeof (uintmax_t)) : (sizeof (void *))))) - 1))
0-79
31 + 4 + ((
(sizeof (long ...of (void *))))Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
sizeof (long double)) > (((sizeof (uintmax_t)) > (sizeof (void *)) ? (sizeof (uintmax_t)) : (sizeof (void *))))
(sizeof (long ...of (void *))))Description
TRUEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
FALSEnever evaluated
? (sizeof (long double)) : (((
(sizeof (uintm...zeof (void *))Description
TRUEnever evaluated
FALSEnever evaluated
sizeof (uintmax_t)) > (sizeof (void *))
(sizeof (uintm...zeof (void *))Description
TRUEnever evaluated
FALSEnever evaluated
? (sizeof (uintmax_t)) : (sizeof (void *))))) - 1)
0-79
32 & ~(((sizeof (long double)) > (((sizeof (uintmax_t)) > (sizeof (void *)) ? (sizeof (uintmax_t)) : (sizeof (void *)))) ? (sizeof (long double)) : (((sizeof (uintmax_t)) > (sizeof (void *)) ? (sizeof (uintmax_t)) : (sizeof (void *))))) - 1));-
33 size = 4096 - extra;-
34 }
executed 79 times by 4 tests: end of block
Executed by:
  • dircolors
  • ls
  • sort
  • wc
79
35-
36 h->chunk_size = size;-
37 h->alignment_mask = alignment - 1;-
38-
39 chunk = h->chunk = call_chunkfun (h, h->chunk_size);-
40 if (!chunk
!chunkDescription
TRUEnever evaluated
FALSEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
)
0-79
41 (*
never executed: (*obstack_alloc_failed_handler) ();
obstack_alloc_failed_handler) ();
never executed: (*obstack_alloc_failed_handler) ();
0
42 h->next_free = h->object_base = ((sizeof (ptrdiff_t) < sizeof (void *)
sizeof (ptrdif...izeof (void *)Description
TRUEnever evaluated
FALSEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
? ((char *) chunk) : (char *) 0) + (((chunk->contents) - (sizeof (ptrdiff_t) < sizeof (void *)
sizeof (ptrdif...izeof (void *)Description
TRUEnever evaluated
FALSEevaluated 79 times by 4 tests
Evaluated by:
  • dircolors
  • ls
  • sort
  • wc
? ((char *) chunk) : (char *) 0) + (alignment - 1)) & ~(alignment - 1)))
0-79
43 ;-
44 h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size;-
45 chunk->prev = 0;-
46-
47 h->maybe_empty_object = 0;-
48 h->alloc_failed = 0;-
49 return
executed 79 times by 4 tests: return 1;
Executed by:
  • dircolors
  • ls
  • sort
  • wc
1;
executed 79 times by 4 tests: return 1;
Executed by:
  • dircolors
  • ls
  • sort
  • wc
79
50}-
51-
52int-
53_obstack_begin (struct obstack *h,-
54 size_t size, size_t alignment,-
55 void *(*chunkfun) (size_t),-
56 void (*freefun) (void *))-
57{-
58 h->chunkfun.plain = chunkfun;-
59 h->freefun.plain = freefun;-
60 h->use_extra_arg = 0;-
61 return
executed 79 times by 4 tests: return _obstack_begin_worker (h, size, alignment);
Executed by:
  • dircolors
  • ls
  • sort
  • wc
_obstack_begin_worker (h, size, alignment);
executed 79 times by 4 tests: return _obstack_begin_worker (h, size, alignment);
Executed by:
  • dircolors
  • ls
  • sort
  • wc
79
62}-
63-
64int-
65_obstack_begin_1 (struct obstack *h,-
66 size_t size, size_t alignment,-
67 void *(*chunkfun) (void *, size_t),-
68 void (*freefun) (void *, void *),-
69 void *arg)-
70{-
71 h->chunkfun.extra = chunkfun;-
72 h->freefun.extra = freefun;-
73 h->extra_arg = arg;-
74 h->use_extra_arg = 1;-
75 return
never executed: return _obstack_begin_worker (h, size, alignment);
_obstack_begin_worker (h, size, alignment);
never executed: return _obstack_begin_worker (h, size, alignment);
0
76}-
77-
78-
79-
80-
81-
82-
83-
84void-
85_obstack_newchunk (struct obstack *h, size_t length)-
86{-
87 struct _obstack_chunk *old_chunk = h->chunk;-
88 struct _obstack_chunk *new_chunk = 0;-
89 size_t obj_size = h->next_free - h->object_base;-
90 char *object_base;-
91-
92-
93 size_t sum1 = obj_size + length;-
94 size_t sum2 = sum1 + h->alignment_mask;-
95 size_t new_size = sum2 + (obj_size >> 3) + 100;-
96 if (new_size < sum2
new_size < sum2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
97 new_size = sum2;
never executed: new_size = sum2;
0
98 if (new_size < h->chunk_size
new_size < h->chunk_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
99 new_size = h->chunk_size;
never executed: new_size = h->chunk_size;
0
100-
101-
102 if (obj_size <= sum1
obj_size <= sum1Description
TRUEnever evaluated
FALSEnever evaluated
&& sum1 <= sum2
sum1 <= sum2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
103 new_chunk = call_chunkfun (h, new_size);
never executed: new_chunk = call_chunkfun (h, new_size);
0
104 if (!new_chunk
!new_chunkDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
105 (*
never executed: (*obstack_alloc_failed_handler)();
obstack_alloc_failed_handler)();
never executed: (*obstack_alloc_failed_handler)();
0
106 h->chunk = new_chunk;-
107 new_chunk->prev = old_chunk;-
108 new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;-
109-
110-
111 object_base =-
112 ((sizeof (ptrdiff_t) < sizeof (void *)
sizeof (ptrdif...izeof (void *)Description
TRUEnever evaluated
FALSEnever evaluated
? ((char *) new_chunk) : (char *) 0) + (((new_chunk->contents) - (sizeof (ptrdiff_t) < sizeof (void *)
sizeof (ptrdif...izeof (void *)Description
TRUEnever evaluated
FALSEnever evaluated
? ((char *) new_chunk) : (char *) 0) + (h->alignment_mask)) & ~(h->alignment_mask)));
0
113-
114-
115 memcpy (object_base, h->object_base, obj_size);-
116-
117-
118-
119-
120 if (!h->maybe_empty_object
!h->maybe_empty_objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
121 && (
(h->object_bas...ment_mask))) )Description
TRUEnever evaluated
FALSEnever evaluated
h->object_base
(h->object_bas...ment_mask))) )Description
TRUEnever evaluated
FALSEnever evaluated
0
122 == ((sizeof (ptrdiff_t) < sizeof (void *) ? ((char *) old_chunk) : (char *) 0) + (((old_chunk->contents) - (sizeof (ptrdiff_t) < sizeof (void *) ? ((char *) old_chunk) : (char *) 0) + (h->alignment_mask)) & ~(h->alignment_mask)))
(h->object_bas...ment_mask))) )Description
TRUEnever evaluated
FALSEnever evaluated
0
123 )
(h->object_bas...ment_mask))) )Description
TRUEnever evaluated
FALSEnever evaluated
)
0
124 {-
125 new_chunk->prev = old_chunk->prev;-
126 call_freefun (h, old_chunk);-
127 }
never executed: end of block
0
128-
129 h->object_base = object_base;-
130 h->next_free = h->object_base + obj_size;-
131-
132 h->maybe_empty_object = 0;-
133}
never executed: end of block
0
134-
135-
136-
137-
138-
139-
140-
141int _obstack_allocated_p (struct obstack *h, void *obj) -
142 __attribute__ ((__pure__))-
143 ;-
144-
145int-
146_obstack_allocated_p (struct obstack *h, void *obj)-
147{-
148 struct _obstack_chunk *lp;-
149 struct _obstack_chunk *plp;-
150-
151 lp = (h)->chunk;-
152-
153-
154-
155 while (lp != 0
lp != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& ((
(void *) lp >= objDescription
TRUEnever evaluated
FALSEnever evaluated
void *) lp >= obj
(void *) lp >= objDescription
TRUEnever evaluated
FALSEnever evaluated
|| (
(void *) (lp)->limit < objDescription
TRUEnever evaluated
FALSEnever evaluated
void *) (lp)->limit < obj
(void *) (lp)->limit < objDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
156 {-
157 plp = lp->prev;-
158 lp = plp;-
159 }
never executed: end of block
0
160 return
never executed: return lp != 0;
lp != 0;
never executed: return lp != 0;
0
161}-
162-
163-
164-
165-
166void-
167_obstack_free (struct obstack *h, void *obj)-
168{-
169 struct _obstack_chunk *lp;-
170 struct _obstack_chunk *plp;-
171-
172 lp = h->chunk;-
173-
174-
175-
176 while (lp != 0
lp != 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • wc
FALSEevaluated 33 times by 1 test
Evaluated by:
  • wc
&& ((
(void *) lp >= objDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • wc
FALSEnever evaluated
void *) lp >= obj
(void *) lp >= objDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • wc
FALSEnever evaluated
|| (
(void *) (lp)->limit < objDescription
TRUEnever evaluated
FALSEnever evaluated
void *) (lp)->limit < obj
(void *) (lp)->limit < objDescription
TRUEnever evaluated
FALSEnever evaluated
))
0-33
177 {-
178 plp = lp->prev;-
179 call_freefun (h, lp);-
180 lp = plp;-
181-
182-
183 h->maybe_empty_object = 1;-
184 }
executed 33 times by 1 test: end of block
Executed by:
  • wc
33
185 if (lp
lpDescription
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • wc
)
0-33
186 {-
187 h->object_base = h->next_free = (char *) (obj);-
188 h->chunk_limit = lp->limit;-
189 h->chunk = lp;-
190 }
never executed: end of block
0
191 else if (obj != 0
obj != 0Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • wc
)
0-33
192-
193 abort ();
never executed: abort ();
0
194}
executed 33 times by 1 test: end of block
Executed by:
  • wc
33
195-
196size_t-
197_obstack_memory_used (struct obstack *h)-
198{-
199 struct _obstack_chunk *lp;-
200 size_t nbytes = 0;-
201-
202 for (lp = h->chunk; lp != 0
lp != 0Description
TRUEnever evaluated
FALSEnever evaluated
; lp = lp->prev)
0
203 {-
204 nbytes += lp->limit - (char *) lp;-
205 }
never executed: end of block
0
206 return
never executed: return nbytes;
nbytes;
never executed: return nbytes;
0
207}-
208-
209-
210-
211-
212-
213-
214-
215-
216-
217-
218-
219-
220-
221-
222static _Noreturn void-
223print_and_abort (void)-
224{-
225 fprintf (-
226 stderr-
227 , "%s\n", -
228 dcgettext (((void *)0), -
229 "memory exhausted"-
230 , 5)-
231 );-
232-
233 exit (exit_failure);
never executed: exit (exit_failure);
0
234}-
235-
236-
237-
238-
239-
240-
241-
242__attribute__ ((__noreturn__)) void (*obstack_alloc_failed_handler) (void)-
243 = print_and_abort;-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2