Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Usage of std::malloc/free prevents global memory allocator cusomization #4569

@sunnlok

Description

@sunnlok

With #4477 the usage of malloc and free was changed to std::malloc and std::free.
While this is most likely the correct approach, it breaks global allocator customization since the std:: variants can not be overriden.
One example would be mimalloc, which redefines these globally.

When such a library or global override is used, you end up with a compilation failure since the "free" in "std::free" is redefined to something else.

An alternative to reverting to global malloc/free could also be the introduction of defines that can be configured along the lines of this:

#ifndef FMT_MALLOC
#define FMT_MALLOC std::malloc
#endif

#ifndef FMT_FREE
#define FMT_FREE std::free
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions