Skip to content

Reserve the global skip_alloc_t variable space correctly #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ unsigned long _dmalloc_alloc_total = 0;
* here. Basically we cannot do a alloc for the structure and we'd
* like it to be static storage so we allocate an array of them to
* make sure we have enough forward pointers, when all we need is
* SKIP_SLOT_SIZE(MAX_SKIP_LEVEL + 1) bytes.
* SKIP_SLOT_SIZE(MAX_SKIP_LEVEL - 1) bytes.
*/
static skip_alloc_t skip_free_alloc[MAX_SKIP_LEVEL /* read note ^^ */];
static skip_alloc_t skip_free_alloc[SKIP_SLOT_COUNT(MAX_SKIP_LEVEL - 1)];
static skip_alloc_t *skip_free_list = skip_free_alloc;

/* skip list of all of our allocated blocks sorted by address */
static skip_alloc_t skip_address_alloc[MAX_SKIP_LEVEL /* read note ^^ */];
static skip_alloc_t skip_address_alloc[SKIP_SLOT_COUNT(MAX_SKIP_LEVEL - 1)];
static skip_alloc_t *skip_address_list = skip_address_alloc;

/* update slots which we use to update the skip lists */
Expand Down
3 changes: 3 additions & 0 deletions chunk_loc.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ typedef struct skip_alloc_st {
#define SKIP_SLOT_SIZE(next_n) \
(sizeof(skip_alloc_t) + sizeof(skip_alloc_t *) * (next_n))

#define SKIP_SLOT_COUNT(next_n) \
DIVUP(SKIP_SLOT_SIZE(next_n), sizeof(skip_alloc_t))

/* entry block magic numbers */
#define ENTRY_BLOCK_MAGIC1 0xEBEB1111 /* for the eb_magic1 field */
#define ENTRY_BLOCK_MAGIC2 0xEBEB2222 /* for the eb_magic2 field */
Expand Down
3 changes: 3 additions & 0 deletions dmalloc_loc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
#undef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))

#undef DIVUP
#define DIVUP(a,b) (((a) + (b) - 1) / (b))

/*
* bitflag tools for Variable and a Flag
*/
Expand Down