0

I am trying to understand zsmalloc allocator used in zram and zswap but I am stuck in code of init_zspage in zsmalloc.c

    link = (struct link_free *)kmap_atomic(page) +
                    off / sizeof(*link);

Here link is not initialized. The problem is what will be the value of sizeof(*link) if it not initializes. As far I know sizeof(*link) must be calculated before assignment.

vivs0766
  • 33
  • 2
  • 6
  • look into http://stackoverflow.com/questions/2731500/using-sizeof-with-a-dynamically-allocated-array – cosinus0 May 20 '15 at 11:11

1 Answers1

0

This size will be computed at compile time.

struct link_free *link;

235 struct link_free {
236         /* Handle of next free chunk (encodes <PFN, obj_idx>) */
237         void *next;
238 };

i.e. size of this struct = size of pointer. So this is what are youasking about?

Alex Hoppus
  • 3,821
  • 4
  • 28
  • 47