Skip to content

Commit

Permalink
feat: support mimalloc (#2135)
Browse files Browse the repository at this point in the history
  • Loading branch information
gremat authored Feb 11, 2025
1 parent 0eb7b3e commit 53642c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 53642c3

Please sign in to comment.