Re: [PATCH v2 4/6] pack-bitmap: prepare to read lookup table extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Taylor Blau <me@xxxxxxxxxxxx> wrote:

> That shouldn't be the case. When you have a chance, take a look at the
> alloc_nr macro, which shows how much memory we allocate at each
> step:
>
>     #define alloc_nr(x) (((x)+16)*3/2)
>
> Suppose we allocated 16 slots initially, so nr (the number of entries
> stored in the list) is 0 and alloc (the number of entries allocated) is
> 16. Then when we try to add the 17th item, we'll pass 16 to alloc_nr
> which will allocate 48 slots. Then 96, then 168, and so on.
>
> We only have to reallocate and copy the array when nr > alloc, which
> should be fairly infrequently, and happens less and less often the
> larger the array grows.

Ohh, I misunderstood the ALLOC_GROW function. Thanks!



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux