Lines Matching refs:mem
16 + * mem.c, opt.h, stats.h: fixed bug #21433: Calling mem_free/pbuf_free from
19 + mem stats.
65 + * mem.h: Fix BUG#23254. Change macro definition of mem_* to allow
77 + * mem.c, tcpip.c, tcpip.h, opt.h: fixed bug #21433 (Calling mem_free/pbuf_free
319 Index: src/core/mem.c
321 RCS file: /sources/lwip/lwip/src/core/mem.c,v
325 --- src/core/mem.c 4 Mar 2008 16:31:32 -0000 1.59
326 +++ src/core/mem.c 30 Jun 2008 18:16:51 -0000 1.62
328 static struct mem *ram_end;
330 static struct mem *lfree;
366 lfree = (struct mem *)ram;
369 - lwip_stats.mem.avail = MEM_SIZE_ALIGNED;
378 struct mem *mem;
397 - ++lwip_stats.mem.err;
400 + /* protect mem stats from concurrent access */
408 /* Get the corresponding struct mem ... */
409 mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM);
412 lfree = mem;
416 - lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram);
418 + MEM_STATS_DEC_USED(used, mem->next - ((u8_t *)mem - ram));
421 plug_holes(mem);
442 struct mem *mem, *mem2;
454 + /* protect mem stats from concurrent access */
460 /* Get the corresponding struct mem ... */
469 - lwip_stats.mem.used -= (size - newsize);
473 mem2 = (struct mem *)&ram[mem->next];
490 struct mem *mem, *mem2;
513 + ptr = ((struct mem *)&ram[ptr])->next) {
514 + mem = (struct mem *)&ram[ptr];
530 - ptr = ((struct mem *)&ram[ptr])->next) {
531 - mem = (struct mem *)&ram[ptr];
533 - if ((!mem->used) &&
534 - (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) {
535 - /* mem is not used and at least perfect fit is possible:
536 - * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */
538 - if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) {
539 - /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing
540 - * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem')
543 - * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size,
544 - * struct mem would fit in but no data between mem2 and mem2->next
546 - * region that couldn't hold data, but when mem->next gets freed,
551 - mem2 = (struct mem *)&ram[ptr2];
553 - mem2->next = mem->next;
555 - /* and insert it between mem and mem->next */
556 - mem->next = ptr2;
557 - mem->used = 1;
560 - ((struct mem *)&ram[mem2->next])->prev = ptr2;
563 - lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
564 - if (lwip_stats.mem.max < lwip_stats.mem.used) {
565 - lwip_stats.mem.max = lwip_stats.mem.used;
566 + if ((!mem->used) &&
567 + (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) {
568 + /* mem is not used and at least perfect fit is possible:
569 + * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */
571 + if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)…
572 + /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containi…
573 + * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem')
576 + * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size,
577 + * struct mem would fit in but no data between mem2 and mem2->next
579 + * region that couldn't hold data, but when mem->next gets freed,
584 + mem2 = (struct mem *)&ram[ptr2];
586 + mem2->next = mem->next;
588 + /* and insert it between mem and mem->next */
589 + mem->next = ptr2;
590 + mem->used = 1;
593 + ((struct mem *)&ram[mem2->next])->prev = ptr2;
597 + /* (a mem2 struct does no fit into the user data space of mem and mem->next will always
601 + * also can't move mem->next directly behind mem, since mem->next
604 + mem->used = 1;
605 + MEM_STATS_INC_USED(used, mem->next - ((u8_t *)mem - ram));
609 - /* (a mem2 struct does no fit into the user data space of mem and mem->next will always
613 - * also can't move mem->next directly behind mem, since mem->next
616 - mem->used = 1;
618 - lwip_stats.mem.used += mem->next - ((u8_t *)mem - ram);
619 - if (lwip_stats.mem.max < lwip_stats.mem.used) {
620 - lwip_stats.mem.max = lwip_stats.mem.used;
625 - if (mem == lfree) {
626 - /* Find next free block after mem and update lowest free pointer */
628 - lfree = (struct mem *)&ram[lfree->next];
629 + if (mem == lfree) {
630 + /* Find next free block after mem and update lowest free pointer */
635 + lfree = (struct mem *)&ram[lfree->next];
643 - (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end);
645 - (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
647 - (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0);
651 + (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end);
653 + (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
655 + (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0);
657 - return (u8_t *)mem + SIZEOF_STRUCT_MEM;
658 + return (u8_t *)mem + SIZEOF_STRUCT_MEM;
668 - ++lwip_stats.mem.err;
724 @@ -365,9 +357,7 @@ memp_free(memp_t type, void *mem)
989 stats_display_mem(struct stats_mem *mem, char *name)
991 @@ -93,48 +95,53 @@ stats_display_mem(struct stats_mem *mem,
992 LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
998 +stats_display_memp(struct stats_mem *mem, int index)
1032 - stats_display_mem(&lwip_stats.mem, "HEAP");
1036 + stats_display_mem(mem, memp_names[index]);
1670 Index: src/include/lwip/mem.h
1672 RCS file: /sources/lwip/lwip/src/include/lwip/mem.h,v
1676 --- src/include/lwip/mem.h 4 Mar 2008 16:31:32 -0000 1.21
1677 +++ src/include/lwip/mem.h 30 May 2008 11:37:15 -0000 1.22
2037 +#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y
2038 +#define MEM_STATS_INC(x) STATS_INC(mem.x)
2039 +#define MEM_STATS_INC_USED(x, y) do { lwip_stats.mem.used += y; \
2040 + if (lwip_stats.mem.max < lwip_stats.mem.used) { \
2041 + lwip_stats.mem.max = lwip_stats.mem.used; \
2044 +#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y
2045 +#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP")
2087 +void stats_display_mem(struct stats_mem *mem, char *name);
2088 +void stats_display_memp(struct stats_mem *mem, int index);
2094 +#define stats_display_mem(mem, name)
2095 +#define stats_display_memp(mem, index)
2212 -#include "lwip/mem.h"