Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 94e75cf in mainline


Ignore:
Timestamp:
2020-06-12T16:40:42Z (3 weeks ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
128359eb
Parents:
265be8a
Message:

Compute the memory area overhead more precisely

The memory area not only contains the desired block, but also its header
and footer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/malloc.c

    r265be8a r94e75cf  
    8181        (sizeof(heap_block_head_t) + sizeof(heap_block_foot_t))
    8282
     83/** Calculate real size of a heap block.
     84 *
     85 * Add header and footer size.
     86 *
     87 */
     88#define GROSS_SIZE(size)  ((size) + STRUCT_OVERHEAD)
     89
     90/** Calculate net size of a heap block.
     91 *
     92 * Subtract header and footer size.
     93 *
     94 */
     95#define NET_SIZE(size)  ((size) - STRUCT_OVERHEAD)
     96
    8397/** Overhead of each area. */
    8498#define AREA_OVERHEAD(size) \
    85         (ALIGN_UP(size + sizeof(heap_area_t), BASE_ALIGN))
    86 
    87 /** Calculate real size of a heap block.
    88  *
    89  * Add header and footer size.
    90  *
    91  */
    92 #define GROSS_SIZE(size)  ((size) + STRUCT_OVERHEAD)
    93 
    94 /** Calculate net size of a heap block.
    95  *
    96  * Subtract header and footer size.
    97  *
    98  */
    99 #define NET_SIZE(size)  ((size) - STRUCT_OVERHEAD)
     99        (ALIGN_UP(GROSS_SIZE(size) + sizeof(heap_area_t), BASE_ALIGN))
    100100
    101101/** Get first block in heap area.
Note: See TracChangeset for help on using the changeset viewer.