mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 13:34:38 +08:00
memp_alloc() now zeroes allocated memory (for robustness). Callers must NOT assume this.
This commit is contained in:
parent
ad55cb6733
commit
3e62b75529
@ -126,8 +126,7 @@ memp_sanity(void)
|
|||||||
if(n == m) {
|
if(n == m) {
|
||||||
--c;
|
--c;
|
||||||
}
|
}
|
||||||
if(c < 0)
|
if(c < 0) return 0; /* LW was: abort(); */
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,6 +177,7 @@ 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);
|
||||||
|
|
||||||
@ -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…
x
Reference in New Issue
Block a user