malloc: fix compile error
diff mbox series

Message ID 1578917307-37611-1-git-send-email-liusirui@huawei.com
State New
Headers show
Series
  • malloc: fix compile error
Related show

Commit Message

liusirui Jan. 13, 2020, 12:08 p.m. UTC
Since e9c4fe93b3855239752819303ca377dff0ed0553, the commit changes struct
malloc_chunk member "size" to "mchunk_size". This cause a compile error
in function dump_heap, if macros MALLOC_DEBUG has defined and the value is
larger 1.

producing the following error message:
In file included from malloc.c:1884:0:
arena.c: In function ‘dump_heap’:
arena.c:422:58: error: ‘struct malloc_chunk’ has no member named ‘size’
       fprintf (stderr, "chunk %p size %10lx", p, (long) p->size);
                                                          ^~
arena.c:428:17: error: ‘struct malloc_chunk’ has no member named ‘size’
       else if (p->size == (0 | PREV_INUSE))
                 ^~
make[2]: *** [../o-iterator.mk:9: /opt/lsr/mainglibc/buildglibc/malloc/malloc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:470: malloc/subdir_lib] Error 2
make: *** [Makefile:9: all] Error 2

---
 malloc/arena.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

liqingqing Jan. 13, 2020, 12:13 p.m. UTC | #1
On 2020/1/13 20:08, liusirui wrote:
> Since e9c4fe93b3855239752819303ca377dff0ed0553, the commit changes struct
> malloc_chunk member "size" to "mchunk_size". This cause a compile error
> in function dump_heap, if macros MALLOC_DEBUG has defined and the value is
> larger 1.

>    for (;; )
>      {
> -      fprintf (stderr, "chunk %p size %10lx", p, (long) p->size);
> +      fprintf (stderr, "chunk %p size %10lx", p, (long) chunksize_nomask(p));
          chunksize_nomask(p) add a white space  like that "chunksize_nomask (p)"
 	

>        if (p == top (heap->ar_ptr))
>          {
>            fprintf (stderr, " (top)\n");
>            break;
>          }
> -      else if (p->size == (0 | PREV_INUSE))
> +      else if (chunksize_nomask(p) == (0 | PREV_INUSE))
	   chunksize_nomask(p) add a white space  like that "chunksize_nomask (p)"

>          {
>            fprintf (stderr, " (fence)\n");
>            break;
>

Patch
diff mbox series

diff --git a/malloc/arena.c b/malloc/arena.c
index 74815ac..be5c9f9 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -419,13 +419,13 @@  dump_heap (heap_info *heap)
                    ~MALLOC_ALIGN_MASK);
   for (;; )
     {
-      fprintf (stderr, "chunk %p size %10lx", p, (long) p->size);
+      fprintf (stderr, "chunk %p size %10lx", p, (long) chunksize_nomask(p));
       if (p == top (heap->ar_ptr))
         {
           fprintf (stderr, " (top)\n");
           break;
         }
-      else if (p->size == (0 | PREV_INUSE))
+      else if (chunksize_nomask(p) == (0 | PREV_INUSE))
         {
           fprintf (stderr, " (fence)\n");
           break;