Skip to content
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

feat: support mimalloc #2135

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@ AC_ARG_WITH([tcmalloc],
PC_REQUIRES_PRIVATE="$PC_REQUIRES_PRIVATE tcmalloc"
fi])

AC_ARG_WITH([mimalloc],
[AS_HELP_STRING([--with-mimalloc],
[use mimalloc as the default heap allocator])],
[if test x$withval = xyes; then
if test "x$with_jemalloc" = "xyes"; then
AC_MSG_ERROR([Cannot compile with both mimalloc and jemalloc])
fi
if test "x$with_tcmalloc" = "xyes"; then
AC_MSG_ERROR([Cannot compile with both mimalloc and tcmalloc])
fi
mi_malloc=mi_malloc
AC_CHECK_LIB(mimalloc, $mi_malloc,,
AC_MSG_ERROR([please install https://github.com/microsoft/mimalloc]))
CFLAGS="$CFLAGS -DMIMALLOC $no_std_allocator"
PC_REQUIRES_PRIVATE="$PC_REQUIRES_PRIVATE mimalloc"
fi])

AC_ARG_WITH([cpu-profiler],
[AS_HELP_STRING([--with-cpu-profiler],
[compile with CPU profiling support])],
Expand Down
4 changes: 4 additions & 0 deletions libyara/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ YR_API void yr_free(void* ptr)
#include <stdlib.h>
#include <string.h>

#if defined(MIMALLOC)
#include <mimalloc-override.h>
#endif

int yr_heap_alloc(void)
{
return ERROR_SUCCESS;
Expand Down
Loading