OpenCoverage

table.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/malloc/table.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* table.c - bookkeeping functions for allocated memory */-
2-
3/* Copyright (C) 2001-2003 Free Software Foundation, Inc.-
4-
5 This file is part of GNU Bash, the Bourne Again SHell.-
6-
7 Bash is free software: you can redistribute it and/or modify-
8 it under the terms of the GNU General Public License as published by-
9 the Free Software Foundation, either version 3 of the License, or-
10 (at your option) any later version.-
11-
12 Bash is distributed in the hope that it will be useful,-
13 but WITHOUT ANY WARRANTY; without even the implied warranty of-
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
15 GNU General Public License for more details.-
16-
17 You should have received a copy of the GNU General Public License-
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.-
19*/-
20-
21#ifdef HAVE_CONFIG_H-
22# include <config.h>-
23#endif-
24-
25#include <stdio.h>-
26#include <string.h>-
27-
28#include "imalloc.h"-
29#include "table.h"-
30-
31#ifdef SHELL-
32extern int interrupt_immediately, running_trap;-
33extern int signal_is_trapped __P((int));-
34#endif-
35-
36extern int malloc_register;-
37-
38#ifdef MALLOC_REGISTER-
39-
40extern FILE *_imalloc_fopen __P((char *, char *, char *, char *, size_t));-
41-
42#define FIND_ALLOC 0x01 /* find slot for new allocation */-
43#define FIND_EXIST 0x02 /* find slot for existing entry for free() or search */-
44-
45static int table_count = 0;-
46static int table_allocated = 0;-
47static int table_bucket_index = REG_TABLE_SIZE-1;-
48static mr_table_t mem_table[REG_TABLE_SIZE];-
49static mr_table_t mem_overflow;-
50-
51#ifndef STREQ-
52#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)-
53#endif-
54-
55static int location_table_index = 0;-
56static int location_table_count = 0;-
57static ma_table_t mlocation_table[REG_TABLE_SIZE];-
58-
59/*-
60 * NOTE: taken from dmalloc (http://dmalloc.com) and modified.-
61 */-
62static unsigned int-
63mt_hash (key)-
64 const PTR_T key;-
65{-
66 unsigned int a, b, c;-
67 unsigned long x;-
68-
69 /* set up the internal state */-
70 a = 0x9e3779b9; /* the golden ratio; an arbitrary value */-
71 x = (unsigned long)key; /* truncation is OK */-
72 b = x >> 8;-
73 c = x >> 3; /* XXX - was >> 4 */-
74-
75 HASH_MIX(a, b, c);-
76 return c;
never executed: return c;
0
77}-
78-
79#if 0-
80static unsigned int-
81which_bucket (mem)-
82 PTR_T mem;-
83{-
84 return (mt_hash ((unsigned char *)mem) & (REG_TABLE_SIZE-1));-
85}-
86-
87#else-
88#define which_bucket(mem) (mt_hash ((unsigned char *)(mem)) & (REG_TABLE_SIZE-1));-
89-
90#define next_bucket() ((table_bucket_index + 1) & (REG_TABLE_SIZE-1))-
91#define next_entry(mem) ((mem == mem_table + REG_TABLE_SIZE - 1) ? mem_table : ++mem)-
92-
93#define prev_bucket() (table_bucket_index == 0 ? REG_TABLE_SIZE-1 : table_bucket_index-1)-
94#define prev_entry(mem) ((mem == mem_table) ? mem_table + REG_TABLE_SIZE - 1 : mem - 1)-
95#endif-
96-
97static mr_table_t *-
98find_entry (mem, flags)-
99 PTR_T mem;-
100 int flags;-
101{-
102 unsigned int bucket;-
103 register mr_table_t *tp;-
104 mr_table_t *endp;-
105-
106 if (mem_overflow.mem == mem)
mem_overflow.mem == memDescription
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
0-Inf
107 return (&mem_overflow);
never executed: return (&mem_overflow);
0
108-
109 /* If we want to insert an allocation entry just use the next slot */-
110 if (flags & FIND_ALLOC)
flags & 0x01Description
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
Inf
111 {-
112 table_bucket_index = next_bucket();-
113 table_count++;-
114 tp = mem_table + table_bucket_index;-
115 memset(tp, 0, sizeof (mr_table_t)); /* overwrite next existing entry */-
116 return tp;
executed 2147483647 times by 1 test: return tp;
Executed by:
  • Self test
Inf
117 }-
118 -
119 tp = endp = mem_table + table_bucket_index;-
120-
121 /* search for last allocation corresponding to MEM, return entry pointer */-
122 while (1)-
123 {-
124 if (tp->mem == mem)
tp->mem == memDescription
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
Inf
125 return (tp);
executed 2147483647 times by 1 test: return (tp);
Executed by:
  • Self test
Inf
126-
127 tp = prev_entry (tp);
(tp == mem_table)Description
TRUEevaluated 140382971 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
140382971-Inf
128-
129 /* if we went all the way around and didn't find it, return NULL */-
130 if (tp == endp)
tp == endpDescription
TRUEevaluated 14615973 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
14615973-Inf
131 return ((mr_table_t *)NULL);
executed 14615973 times by 1 test: return ((mr_table_t *) ((void *)0) );
Executed by:
  • Self test
14615973
132 }
executed 2147483647 times by 1 test: end of block
Executed by:
  • Self test
Inf
133-
134 return (mr_table_t *)NULL;
never executed: return (mr_table_t *) ((void *)0) ;
0
135}-
136-
137mr_table_t *-
138mr_table_entry (mem)-
139 PTR_T mem;-
140{-
141 return (find_entry (mem, FIND_EXIST));
never executed: return (find_entry (mem, 0x02));
0
142}-
143-
144void-
145mregister_describe_mem (mem, fp)-
146 PTR_T mem;-
147 FILE *fp;-
148{-
149 mr_table_t *entry;-
150-
151 entry = find_entry (mem, FIND_EXIST);-
152 if (entry == 0)
entry == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
153 return;
never executed: return;
0
154 fprintf (fp, "malloc: %p: %s: last %s from %s:%d\n",-
155 mem,-
156 (entry->flags & MT_ALLOC) ? "allocated" : "free",-
157 (entry->flags & MT_ALLOC) ? "allocated" : "freed",-
158 entry->file ? entry->file : "unknown",-
159 entry->line);-
160}
never executed: end of block
0
161-
162void-
163mregister_alloc (tag, mem, size, file, line)-
164 const char *tag;-
165 PTR_T mem;-
166 size_t size;-
167 const char *file;-
168 int line;-
169{-
170 mr_table_t *tentry;-
171 sigset_t set, oset;-
172 int blocked_sigs;-
173-
174 /* Block all signals in case we are executed from a signal handler. */-
175 blocked_sigs = 0;-
176#ifdef SHELL-
177 if (interrupt_immediately || running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
interrupt_immediatelyDescription
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
running_trapDescription
TRUEevaluated 308689 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
signal_is_trapped ( 2 )Description
TRUEevaluated 10184 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
signal_is_trapped ( 17 )Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
0-Inf
178#endif-
179 {-
180 _malloc_block_signals (&set, &oset);-
181 blocked_sigs = 1;-
182 }
executed 318926 times by 1 test: end of block
Executed by:
  • Self test
318926
183-
184 mlocation_register_alloc (file, line);-
185-
186 tentry = find_entry (mem, FIND_ALLOC);-
187-
188 if (tentry == 0)
tentry == 0Description
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
0-Inf
189 {-
190 /* oops. table is full. punt. */-
191 fprintf (stderr, _("register_alloc: alloc table is full with FIND_ALLOC?\n"));-
192 if (blocked_sigs)
blocked_sigsDescription
TRUEnever evaluated
FALSEnever evaluated
0
193 _malloc_unblock_signals (&set, &oset);
never executed: _malloc_unblock_signals (&set, &oset);
0
194 return;
never executed: return;
0
195 }-
196 -
197 if (tentry->flags & MT_ALLOC)
tentry->flags & 0x01Description
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
0-Inf
198 {-
199 /* oops. bad bookkeeping. ignore for now */-
200 fprintf (stderr, _("register_alloc: %p already in table as allocated?\n"), mem);-
201 }
never executed: end of block
0
202-
203 tentry->mem = mem;-
204 tentry->size = size;-
205 tentry->func = tag;-
206 tentry->flags = MT_ALLOC;-
207 tentry->file = file;-
208 tentry->line = line;-
209 tentry->nalloc++;-
210-
211 if (tentry != &mem_overflow)
tentry != &mem_overflowDescription
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-Inf
212 table_allocated++;
executed 2147483647 times by 1 test: table_allocated++;
Executed by:
  • Self test
Inf
213-
214 if (blocked_sigs)
blocked_sigsDescription
TRUEevaluated 318926 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
318926-Inf
215 _malloc_unblock_signals (&set, &oset);
executed 318926 times by 1 test: _malloc_unblock_signals (&set, &oset);
Executed by:
  • Self test
318926
216}
executed 2147483647 times by 1 test: end of block
Executed by:
  • Self test
Inf
217-
218void-
219mregister_free (mem, size, file, line)-
220 PTR_T mem;-
221 int size;-
222 const char *file;-
223 int line;-
224{-
225 mr_table_t *tentry;-
226 sigset_t set, oset;-
227 int blocked_sigs;-
228-
229 /* Block all signals in case we are executed from a signal handler. */-
230 blocked_sigs = 0;-
231#ifdef SHELL-
232 if (interrupt_immediately || running_trap || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
interrupt_immediatelyDescription
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
running_trapDescription
TRUEevaluated 292347 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
signal_is_trapped ( 2 )Description
TRUEevaluated 10902 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
signal_is_trapped ( 17 )Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
0-Inf
233#endif-
234 {-
235 _malloc_block_signals (&set, &oset);-
236 blocked_sigs = 1;-
237 }
executed 303309 times by 1 test: end of block
Executed by:
  • Self test
303309
238-
239 tentry = find_entry (mem, FIND_EXIST);-
240 if (tentry == 0)
tentry == 0Description
TRUEevaluated 14615973 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
14615973-Inf
241 {-
242 /* oops. not found. */-
243#if 0-
244 fprintf (stderr, "register_free: %p not in allocation table?\n", mem);-
245#endif-
246 if (blocked_sigs)
blocked_sigsDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14615901 times by 1 test
Evaluated by:
  • Self test
72-14615901
247 _malloc_unblock_signals (&set, &oset);
executed 72 times by 1 test: _malloc_unblock_signals (&set, &oset);
Executed by:
  • Self test
72
248 return;
executed 14615973 times by 1 test: return;
Executed by:
  • Self test
14615973
249 }-
250 if (tentry->flags & MT_FREE)
tentry->flags & 0x02Description
TRUEnever evaluated
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
0-Inf
251 {-
252 /* oops. bad bookkeeping. ignore for now */-
253 fprintf (stderr, _("register_free: %p already in table as free?\n"), mem);-
254 }
never executed: end of block
0
255 -
256 tentry->flags = MT_FREE;-
257 tentry->func = "free";-
258 tentry->file = file;-
259 tentry->line = line;-
260 tentry->nfree++;-
261-
262 if (tentry != &mem_overflow)
tentry != &mem_overflowDescription
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-Inf
263 table_allocated--;
executed 2147483647 times by 1 test: table_allocated--;
Executed by:
  • Self test
Inf
264-
265 if (blocked_sigs)
blocked_sigsDescription
TRUEevaluated 303237 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
303237-Inf
266 _malloc_unblock_signals (&set, &oset);
executed 303237 times by 1 test: _malloc_unblock_signals (&set, &oset);
Executed by:
  • Self test
303237
267}
executed 2147483647 times by 1 test: end of block
Executed by:
  • Self test
Inf
268-
269/* If we ever add more flags, this will require changes. */-
270static char *-
271_entry_flags(x)-
272 int x;-
273{-
274 if (x & MT_FREE)
x & 0x02Description
TRUEnever evaluated
FALSEnever evaluated
0
275 return "free";
never executed: return "free";
0
276 else if (x & MT_ALLOC)
x & 0x01Description
TRUEnever evaluated
FALSEnever evaluated
0
277 return "allocated";
never executed: return "allocated";
0
278 else-
279 return "undetermined?";
never executed: return "undetermined?";
0
280}-
281-
282static void-
283_register_dump_table(fp)-
284 FILE *fp;-
285{-
286 register int i;-
287 mr_table_t entry;-
288-
289 for (i = 0; i < REG_TABLE_SIZE; i++)
i < 8192Description
TRUEnever evaluated
FALSEnever evaluated
0
290 {-
291 entry = mem_table[i];-
292 if (entry.mem)
entry.memDescription
TRUEnever evaluated
FALSEnever evaluated
0
293 fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n",
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
294 (i == table_bucket_index) ? "*" : "",
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
295 i,
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
296 entry.mem, entry.size,
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
297 _entry_flags(entry.flags),
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
298 entry.func ? entry.func : "unknown",
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
299 entry.file ? entry.file : "unknown",
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
300 entry.line,
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
301 entry.nalloc, entry.nfree);
never executed: fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n", (i == table_bucket_index) ? "*" : "", i, entry.mem, entry.size, _entry_flags(entry.flags), entry.func ? entry.func : "unknown", entry.file ? entry.file : "unknown", entry.line, entry.nalloc, entry.nfree);
0
302 }
never executed: end of block
0
303}
never executed: end of block
0
304 -
305void-
306mregister_dump_table()-
307{-
308 _register_dump_table (stderr);-
309}
never executed: end of block
0
310-
311void-
312mregister_table_init ()-
313{-
314 memset (mem_table, 0, sizeof(mr_table_t) * REG_TABLE_SIZE);-
315 memset (&mem_overflow, 0, sizeof (mr_table_t));-
316 table_count = 0;-
317}
never executed: end of block
0
318-
319/* Simple for now */-
320-
321static ma_table_t *-
322find_location_entry (file, line)-
323 const char *file;-
324 int line;-
325{-
326 register ma_table_t *tp, *endp;-
327-
328 endp = mlocation_table + location_table_count;-
329 for (tp = mlocation_table; tp <= endp; tp++)
tp <= endpDescription
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 660636 times by 1 test
Evaluated by:
  • Self test
660636-Inf
330 {-
331 if (tp->line == line && STREQ (file, tp->file))
never executed: __result = (((const unsigned char *) (const char *) ( file ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( tp->file ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
tp->line == lineDescription
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
(file)[0] == (tp->file)[0]Description
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1687675 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 591 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-Inf
332 return tp;
executed 2147483647 times by 1 test: return tp;
Executed by:
  • Self test
Inf
333 }
executed 2147483647 times by 1 test: end of block
Executed by:
  • Self test
Inf
334 return (ma_table_t *)NULL;
executed 660636 times by 1 test: return (ma_table_t *) ((void *)0) ;
Executed by:
  • Self test
660636
335}-
336-
337void-
338mlocation_register_alloc (file, line)-
339 const char *file;-
340 int line;-
341{-
342 ma_table_t *lentry;-
343 const char *nfile;-
344-
345 if (file == 0)
file == 0Description
TRUEevaluated 121534248 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
121534248-Inf
346 {-
347 mlocation_table[0].nalloc++;-
348 return;
executed 121534248 times by 1 test: return;
Executed by:
  • Self test
121534248
349 }-
350-
351 nfile = strrchr (file, '/');-
352 if (nfile)
nfileDescription
TRUEevaluated 8798396 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
8798396-Inf
353 nfile++;
executed 8798396 times by 1 test: nfile++;
Executed by:
  • Self test
8798396
354 else-
355 nfile = file;
executed 2147483647 times by 1 test: nfile = file;
Executed by:
  • Self test
Inf
356-
357 lentry = find_location_entry (nfile, line);-
358 if (lentry == 0)
lentry == 0Description
TRUEevaluated 660636 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2147483647 times by 1 test
Evaluated by:
  • Self test
660636-Inf
359 {-
360 location_table_index++;-
361 if (location_table_index == REG_TABLE_SIZE)
location_table_index == 8192Description
TRUEnever evaluated
FALSEevaluated 660636 times by 1 test
Evaluated by:
  • Self test
0-660636
362 location_table_index = 1; /* slot 0 reserved */
never executed: location_table_index = 1;
0
363 lentry = mlocation_table + location_table_index;-
364 lentry->file = nfile;-
365 lentry->line = line;-
366 lentry->nalloc = 1;-
367 if (location_table_count < REG_TABLE_SIZE)
location_table_count < 8192Description
TRUEevaluated 660636 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-660636
368 location_table_count++; /* clamp at REG_TABLE_SIZE for now */
executed 660636 times by 1 test: location_table_count++;
Executed by:
  • Self test
660636
369 }
executed 660636 times by 1 test: end of block
Executed by:
  • Self test
660636
370 else-
371 lentry->nalloc++;
executed 2147483647 times by 1 test: lentry->nalloc++;
Executed by:
  • Self test
Inf
372}-
373-
374static void-
375_location_dump_table (fp)-
376 FILE *fp;-
377{-
378 register ma_table_t *tp, *endp;-
379-
380 endp = mlocation_table + location_table_count;-
381 for (tp = mlocation_table; tp < endp; tp++)
tp < endpDescription
TRUEnever evaluated
FALSEnever evaluated
0
382 fprintf (fp, "%s:%d\t%d\n", tp->file ? tp->file : "unknown",
never executed: fprintf (fp, "%s:%d\t%d\n", tp->file ? tp->file : "unknown", tp->line ? tp->line : 0, tp->nalloc);
0
383 tp->line ? tp->line : 0,
never executed: fprintf (fp, "%s:%d\t%d\n", tp->file ? tp->file : "unknown", tp->line ? tp->line : 0, tp->nalloc);
0
384 tp->nalloc);
never executed: fprintf (fp, "%s:%d\t%d\n", tp->file ? tp->file : "unknown", tp->line ? tp->line : 0, tp->nalloc);
0
385}
never executed: end of block
0
386-
387void-
388mlocation_dump_table ()-
389{-
390 _location_dump_table (stderr);-
391}
never executed: end of block
0
392-
393#define LOCROOT "/var/tmp/maltrace/locations."-
394-
395void-
396mlocation_write_table ()-
397{-
398 FILE *fp;-
399 char defname[sizeof (LOCROOT) + 64];-
400-
401 fp = _imalloc_fopen ((char *)NULL, (char *)NULL, LOCROOT, defname, sizeof (defname));-
402 if (fp == 0)
fp == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
403 return; /* XXX - no error message yet */
never executed: return;
0
404 _location_dump_table (fp);-
405 fclose (fp);-
406}
never executed: end of block
0
407-
408void-
409mlocation_table_init ()-
410{-
411 memset (mlocation_table, 0, sizeof (ma_table_t) * REG_TABLE_SIZE);-
412 mlocation_table[0].file = ""; /* reserve slot 0 for unknown locations */-
413 mlocation_table[0].line = 0;-
414 mlocation_table[0].nalloc = 0;-
415 location_table_count = 1;-
416}
never executed: end of block
0
417-
418#endif /* MALLOC_REGISTER */-
419-
420int-
421malloc_set_register(n)-
422 int n;-
423{-
424 int old;-
425-
426 old = malloc_register;-
427 malloc_register = n;-
428 return old;
executed 5432 times by 1 test: return old;
Executed by:
  • Self test
5432
429}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2