mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-15 22:49:16 +00:00
Fix bug #21077: inaccuracy in calculation of lwip_stat.mem.used
This commit is contained in:
parent
036d1aae50
commit
93c487fb75
@ -455,6 +455,12 @@ mem_malloc(mem_size_t size)
|
|||||||
if (mem2->next != MEM_SIZE_ALIGNED) {
|
if (mem2->next != MEM_SIZE_ALIGNED) {
|
||||||
((struct mem *)&ram[mem2->next])->prev = ptr2;
|
((struct mem *)&ram[mem2->next])->prev = ptr2;
|
||||||
}
|
}
|
||||||
|
#if MEM_STATS
|
||||||
|
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
|
||||||
|
if (lwip_stats.mem.max < lwip_stats.mem.used) {
|
||||||
|
lwip_stats.mem.max = lwip_stats.mem.used;
|
||||||
|
}
|
||||||
|
#endif /* MEM_STATS */
|
||||||
} else {
|
} else {
|
||||||
/* (a mem2 struct does no fit into the user data space of mem and mem->next will always
|
/* (a mem2 struct does no fit into the user data space of mem and mem->next will always
|
||||||
* be used at this point: if not we have 2 unused structs in a row, plug_holes should have
|
* be used at this point: if not we have 2 unused structs in a row, plug_holes should have
|
||||||
@ -464,14 +470,14 @@ mem_malloc(mem_size_t size)
|
|||||||
* will always be used at this point!
|
* will always be used at this point!
|
||||||
*/
|
*/
|
||||||
mem->used = 1;
|
mem->used = 1;
|
||||||
}
|
|
||||||
|
|
||||||
#if MEM_STATS
|
#if MEM_STATS
|
||||||
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
|
lwip_stats.mem.used += mem->next - ((u8_t *)mem - ram);
|
||||||
if (lwip_stats.mem.max < lwip_stats.mem.used) {
|
if (lwip_stats.mem.max < lwip_stats.mem.used) {
|
||||||
lwip_stats.mem.max = lwip_stats.mem.used;
|
lwip_stats.mem.max = lwip_stats.mem.used;
|
||||||
}
|
}
|
||||||
#endif /* MEM_STATS */
|
#endif /* MEM_STATS */
|
||||||
|
}
|
||||||
|
|
||||||
if (mem == lfree) {
|
if (mem == lfree) {
|
||||||
/* Find next free block after mem and update lowest free pointer */
|
/* Find next free block after mem and update lowest free pointer */
|
||||||
while (lfree->used && lfree != ram_end) {
|
while (lfree->used && lfree != ram_end) {
|
||||||
|
Loading…
Reference in New Issue
Block a user