Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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