diff --git a/CHANGELOG b/CHANGELOG index 2038d9ea..7221e02e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -125,6 +125,10 @@ HISTORY ++ Bug fixes: + 2007-05-04 Simon Goldschmidt + * memp.c: checked in patch #5913: in memp_malloc() we can return memp as mem + to save a little RAM (next pointer of memp is not used while not in pool). + 2007-05-03 "maq" * sockets.c: Fix ioctl FIONREAD when some data remains from last recv. (patch #3574). diff --git a/src/core/memp.c b/src/core/memp.c index 156117ce..b43529d3 100644 --- a/src/core/memp.c +++ b/src/core/memp.c @@ -165,7 +165,6 @@ void * memp_malloc(memp_t type) { struct memp *memp; - void *mem; #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_DECL_PROTECT(old_level); #endif @@ -189,7 +188,6 @@ memp_malloc(memp_t type) lwip_stats.memp[type].max = lwip_stats.memp[type].used; } #endif /* MEMP_STATS */ - mem = (u8_t *)memp + MEMP_SIZE; LWIP_ASSERT("memp_malloc: memp properly aligned", ((mem_ptr_t)memp % MEM_ALIGNMENT) == 0); } else { @@ -197,7 +195,6 @@ memp_malloc(memp_t type) #if MEMP_STATS ++lwip_stats.memp[type].err; #endif /* MEMP_STATS */ - mem = NULL; } #if SYS_LIGHTWEIGHT_PROT @@ -206,7 +203,7 @@ memp_malloc(memp_t type) sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ - return mem; + return (void*)memp; } void @@ -220,8 +217,10 @@ memp_free(memp_t type, void *mem) if (mem == NULL) { return; } + LWIP_ASSERT("memp_free: mem properly aligned", + ((mem_ptr_t)mem % MEM_ALIGNMENT) == 0); - memp = (struct memp *)((u8_t *)mem - MEMP_SIZE); + memp = (struct memp *)mem; #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_PROTECT(old_level);