Skip to content

Add #ifdef so that using custom malloc() is streamlined #39

Open
@dtromb

Description

@dtromb

Right now the source must by modified to use a custom malloc. From dict.c:

void* (*dict_malloc_func)(size_t) = malloc;
void (*dict_free_func)(void*) = free;

These functions cannot be changed after compilation, so we must edit dict.c to customize, adding CM complexity.
I propose the simple change:

#ifndef LIBDICT_USE_CUSTOM_MALLOC
void* (*dict_malloc_func)(size_t) = malloc;
void (*dict_free_func)(void*) = free;
#endif

In this way, the object can be compiled without those symbols defined, so that they can be linked in later.
The Makefile must also be changed to support this somehow, to pass the define through on CFLAGS, and also so that tests / pothe binaries built be the Makefile will either get linked with a version of dict.o with those symbols, or their own copies of the symbol definitions if the custom malloc is requested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions