Deleted Added
full compact
zalloc_malloc.c (124570) zalloc_malloc.c (126206)
1/*
2 * This module derived from code donated to the FreeBSD Project by
3 * Matthew Dillon <dillon@backplane.com>
4 *
5 * Copyright (c) 1998 The FreeBSD Project
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*
2 * This module derived from code donated to the FreeBSD Project by
3 * Matthew Dillon <dillon@backplane.com>
4 *
5 * Copyright (c) 1998 The FreeBSD Project
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/lib/libstand/zalloc_malloc.c 124570 2004-01-15 18:35:32Z jhb $");
31__FBSDID("$FreeBSD: head/lib/libstand/zalloc_malloc.c 126206 2004-02-25 00:52:14Z grehan $");
32
33/*
34 * MALLOC.C - malloc equivalent, runs on top of zalloc and uses sbrk
35 */
36
37#include "zalloc_defs.h"
38
39static MemPool MallocPool;

--- 43 unchanged lines hidden (view full) ---

83 if (++MallocCount > MallocMax)
84 MallocMax = MallocCount;
85#endif
86#ifdef USEGUARD
87 res->ga_Magic = GAMAGIC;
88#endif
89 res->ga_Bytes = bytes;
90#ifdef USEENDGUARD
32
33/*
34 * MALLOC.C - malloc equivalent, runs on top of zalloc and uses sbrk
35 */
36
37#include "zalloc_defs.h"
38
39static MemPool MallocPool;

--- 43 unchanged lines hidden (view full) ---

83 if (++MallocCount > MallocMax)
84 MallocMax = MallocCount;
85#endif
86#ifdef USEGUARD
87 res->ga_Magic = GAMAGIC;
88#endif
89 res->ga_Bytes = bytes;
90#ifdef USEENDGUARD
91 *((char *)res + bytes - 1) = -2;
91 *((signed char *)res + bytes - 1) = -2;
92#endif
92#endif
93
93 return((char *)res + MALLOCALIGN);
94}
95
96void
97Free(void *ptr, const char *file, int line)
98{
99 size_t bytes;
100

--- 7 unchanged lines hidden (view full) ---

108 printf("free: duplicate free @ %p from %s:%d\n", ptr, file, line);
109 return;
110 }
111 if (res->ga_Magic != GAMAGIC)
112 panic("free: guard1 fail @ %p from %s:%d", ptr, file, line);
113 res->ga_Magic = GAFREE;
114#endif
115#ifdef USEENDGUARD
94 return((char *)res + MALLOCALIGN);
95}
96
97void
98Free(void *ptr, const char *file, int line)
99{
100 size_t bytes;
101

--- 7 unchanged lines hidden (view full) ---

109 printf("free: duplicate free @ %p from %s:%d\n", ptr, file, line);
110 return;
111 }
112 if (res->ga_Magic != GAMAGIC)
113 panic("free: guard1 fail @ %p from %s:%d", ptr, file, line);
114 res->ga_Magic = GAFREE;
115#endif
116#ifdef USEENDGUARD
116 if (*((char *)res + res->ga_Bytes - 1) == -1) {
117 if (*((signed char *)res + res->ga_Bytes - 1) == -1) {
117 printf("free: duplicate2 free @ %p from %s:%d\n", ptr, file, line);
118 return;
119 }
118 printf("free: duplicate2 free @ %p from %s:%d\n", ptr, file, line);
119 return;
120 }
120 if (*((char *)res + res->ga_Bytes - 1) != -2)
121 if (*((signed char *)res + res->ga_Bytes - 1) != -2)
121 panic("free: guard2 fail @ %p + %d from %s:%d", ptr, res->ga_Bytes - MALLOCALIGN, file, line);
122 panic("free: guard2 fail @ %p + %d from %s:%d", ptr, res->ga_Bytes - MALLOCALIGN, file, line);
122 *((char *)res + res->ga_Bytes - 1) = -1;
123 *((signed char *)res + res->ga_Bytes - 1) = -1;
123#endif
124
125 bytes = res->ga_Bytes;
126 zfree(&MallocPool, res, bytes);
127#ifdef DMALLOCDEBUG
128 --MallocCount;
129#endif
130 }

--- 78 unchanged lines hidden ---
124#endif
125
126 bytes = res->ga_Bytes;
127 zfree(&MallocPool, res, bytes);
128#ifdef DMALLOCDEBUG
129 --MallocCount;
130#endif
131 }

--- 78 unchanged lines hidden ---