mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
memp_alloc() now zeroes allocated memory (for robustness). Callers must NOT assume this.
This commit is contained in:
parent
ad55cb6733
commit
3e62b75529
@ -118,16 +118,15 @@ memp_sanity(void)
|
|||||||
{
|
{
|
||||||
int i, c;
|
int i, c;
|
||||||
struct memp *m, *n;
|
struct memp *m, *n;
|
||||||
|
|
||||||
for(i = 0; i < MEMP_MAX; i++) {
|
for(i = 0; i < MEMP_MAX; i++) {
|
||||||
for(m = memp_tab[i]; m != NULL; m = m->next) {
|
for(m = memp_tab[i]; m != NULL; m = m->next) {
|
||||||
c = 1;
|
c = 1;
|
||||||
for(n = memp_tab[i]; n != NULL; n = n->next) {
|
for(n = memp_tab[i]; n != NULL; n = n->next) {
|
||||||
if(n == m) {
|
if(n == m) {
|
||||||
--c;
|
--c;
|
||||||
}
|
}
|
||||||
if(c < 0)
|
if(c < 0) return 0; /* LW was: abort(); */
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +177,8 @@ void *
|
|||||||
memp_malloc(memp_t type)
|
memp_malloc(memp_t type)
|
||||||
{
|
{
|
||||||
struct memp *memp;
|
struct memp *memp;
|
||||||
|
void *mem;
|
||||||
|
|
||||||
ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX);
|
ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX);
|
||||||
|
|
||||||
memp = memp_tab[type];
|
memp = memp_tab[type];
|
||||||
@ -195,7 +195,10 @@ memp_malloc(memp_t type)
|
|||||||
ASSERT("memp_malloc: memp properly aligned",
|
ASSERT("memp_malloc: memp properly aligned",
|
||||||
((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);
|
||||||
|
|
||||||
return MEM_ALIGN((u8_t *)memp + sizeof(struct memp));
|
mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp));
|
||||||
|
/* initialize memp memory with zeroes */
|
||||||
|
bzero(mem, memp_sizes[type]);
|
||||||
|
return mem;
|
||||||
} else {
|
} else {
|
||||||
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));
|
||||||
#ifdef MEMP_STATS
|
#ifdef MEMP_STATS
|
||||||
|
Loading…
Reference in New Issue
Block a user