118 |
{ |
{ |
119 |
int i, c; |
int i, c; |
120 |
struct memp *m, *n; |
struct memp *m, *n; |
121 |
|
|
122 |
for(i = 0; i < MEMP_MAX; i++) { |
for(i = 0; i < MEMP_MAX; i++) { |
123 |
for(m = memp_tab[i]; m != NULL; m = m->next) { |
for(m = memp_tab[i]; m != NULL; m = m->next) { |
124 |
c = 1; |
c = 1; |
125 |
for(n = memp_tab[i]; n != NULL; n = n->next) { |
for(n = memp_tab[i]; n != NULL; n = n->next) { |
126 |
if(n == m) { |
if(n == m) { |
127 |
--c; |
--c; |
128 |
} |
} |
129 |
if(c < 0) |
if(c < 0) return 0; /* LW was: abort(); */ |
|
abort(); |
|
130 |
} |
} |
131 |
} |
} |
132 |
} |
} |
177 |
memp_malloc(memp_t type) |
memp_malloc(memp_t type) |
178 |
{ |
{ |
179 |
struct memp *memp; |
struct memp *memp; |
180 |
|
void *mem; |
181 |
|
|
182 |
ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX); |
ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX); |
183 |
|
|
184 |
memp = memp_tab[type]; |
memp = memp_tab[type]; |
195 |
ASSERT("memp_malloc: memp properly aligned", |
ASSERT("memp_malloc: memp properly aligned", |
196 |
((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0); |
((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0); |
197 |
|
|
198 |
return MEM_ALIGN((u8_t *)memp + sizeof(struct memp)); |
mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp)); |
199 |
|
/* initialize memp memory with zeroes */ |
200 |
|
bzero(mem, memp_sizes[type]); |
201 |
|
return mem; |
202 |
} else { |
} else { |
203 |
DEBUGF(MEMP_DEBUG, ("memp_malloc: out of memory in pool %d\n", type)); |
DEBUGF(MEMP_DEBUG, ("memp_malloc: out of memory in pool %d\n", type)); |
204 |
#ifdef MEMP_STATS |
#ifdef MEMP_STATS |