Skip to content

Commit

Permalink
Remove the unused dlmalloc implementation.
Browse files Browse the repository at this point in the history
A possible cross-platform replacement, with excellent performance, would be mimalloc.
  • Loading branch information
KubaO committed Jun 30, 2023
1 parent a7eb4bb commit 0174e35
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6,099 deletions.
1 change: 0 additions & 1 deletion src/smbase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ add_library(smbase STATIC
growbuf.cc
hashline.cc
hashtbl.cc
malloc_stub.c
mysig.cc
nonport.cpp
point.cc
Expand Down
30 changes: 16 additions & 14 deletions src/smbase/ckheap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ckheap.h see license.txt for copyright and terms of use
// interface to check heap integrity, etc.
// Hooks called by the rest of the code, to allow plugging in a heap
// checker.

#ifndef CKHEAP_H
#define CKHEAP_H
Expand All @@ -9,21 +10,14 @@ extern "C" {
#endif


#ifdef __WIN32__
// don't want to try to get dlmalloc working...
#define checkHeapNode(n) /*nothing*/
#define malloc_stats() ((void)0)
#else


// check heap integrity, and fail an assertion if it's bad
// Hook to check heap integrity, and fail an assertion if it's bad
void checkHeap();

// check that a given pointer is a valid allocated object;
// Hook to check that a given pointer is a valid allocated object;
// fail assertion if not
void checkHeapNode(void *node);
void checkHeapNode(void* node);

// prints allocation statistics to stderr
// Hook to print allocation statistics to stderr
void malloc_stats();

// count # of malloc/free calls in program
Expand All @@ -47,11 +41,19 @@ enum HeapWalkOpts {
// (you can cause 'block' to be freed by returning HW_FREE)
typedef enum HeapWalkOpts (*HeapWalkFn)(void *block, int size);

// heap walk entry
// Hook for a heap walk
void walkMallocHeap(HeapWalkFn func);

#ifndef ELK_USE_HEAP_CHECKER

inline void checkHeap() {}
inline void checkHeapNode(void* node) { (void)node; }
inline void malloc_stats() {}
inline unsigned numMallocCalls() { return 0; }
inline unsigned numFreeCalls() { return 0; }
inline void walkMallocHeap(HeapWalkFn func) { (void)func; }

#endif // !__WIN32__
#endif // ELK_USE_HEAP_CHECKER

#ifdef __cplusplus
} // extern "C"
Expand Down
Loading

0 comments on commit 0174e35

Please sign in to comment.