Lolly 1.4.28
Loading...
Searching...
No Matches
Functions
mi_malloc.cpp File Reference
#include "assert.h"
#include "basic.hpp"
#include "fast_alloc.hpp"
#include "tm_ostream.hpp"
#include <errno.h>
#include <mimalloc.h>
Include dependency graph for mi_malloc.cpp:

Go to the source code of this file.

Functions

voidfast_alloc (size_t sz)
 
void fast_free (void *ptr, size_t sz)
 
voidfast_realloc (void *ptr, size_t, size_t new_size)
 
voidfast_new (size_t s)
 
void fast_delete (void *ptr)
 
bool visit_mem (const mi_heap_t *heap, const mi_heap_area_t *heapinfo, void *block, size_t blocksize, void *arg)
 
int mem_used ()
 
void mem_info ()
 
void mem_err_handler (int err, void *arg)
 
void mem_init ()
 

Function Documentation

◆ fast_alloc()

void * fast_alloc ( size_t sz)

Definition at line 24 of file mi_malloc.cpp.

24 {
25 return mi_malloc (sz);
26}
The list class represents a linked list.
Definition list.hpp:48

◆ fast_free()

void fast_free ( void * ptr,
size_t sz )

Definition at line 29 of file mi_malloc.cpp.

29 {
30 mi_free (ptr);
31}

◆ fast_realloc()

void * fast_realloc ( void * ptr,
size_t old_size,
size_t new_size )

Definition at line 34 of file mi_malloc.cpp.

34 {
35 return mi_realloc (ptr, new_size);
36}

◆ fast_new()

void * fast_new ( size_t s)

Definition at line 39 of file mi_malloc.cpp.

39 {
40 return mi_malloc (s);
41}

◆ fast_delete()

void fast_delete ( void * ptr)

Definition at line 44 of file mi_malloc.cpp.

44 {
45 mi_free (ptr);
46}

◆ visit_mem()

bool visit_mem ( const mi_heap_t * heap,
const mi_heap_area_t * heapinfo,
void * block,
size_t blocksize,
void * arg )

Definition at line 53 of file mi_malloc.cpp.

54 {
55 int* count= (int*) arg;
56 *count+= heapinfo->used;
57 return true;
58}

◆ mem_used()

int mem_used ( )

Definition at line 61 of file mi_malloc.cpp.

61 {
63 int count= 0;
65 return count;
66}
bool visit_mem(const mi_heap_t *heap, const mi_heap_area_t *heapinfo, void *block, size_t blocksize, void *arg)
Definition mi_malloc.cpp:53

◆ mem_info()

void mem_info ( )

Definition at line 69 of file mi_malloc.cpp.

69 {
70 cout << "\n---------------- memory statistics ----------------\n";
71 cout << "malloc overrided:" << mi_is_redirected () << "\n";
72}
tm_ostream & cout

◆ mem_err_handler()

void mem_err_handler ( int err,
void * arg )

Definition at line 75 of file mi_malloc.cpp.

75 {
76 switch (err) {
77 case ENOMEM:
78 cerr << "Fatal error: out of memory\n";
79 break;
80 case EINVAL:
81 cerr << "Fatal error: invalid pointer\n";
82 break;
83 case EFAULT:
84 cerr << "Corrupted heap. Please check whether there are objects used after "
85 "free.\n";
86 break;
87 case EOVERFLOW:
88 cerr << "Fatal error: input argument of allocator is too large\n";
89 break;
90 case EAGAIN:
91 cerr << "Double free detected\n";
92 break;
93 default:
94 break;
95 }
96 abort ();
97}
tm_ostream & cerr

◆ mem_init()

void mem_init ( )

Definition at line 100 of file mi_malloc.cpp.

100 {
102}
void mem_err_handler(int err, void *arg)
Definition mi_malloc.cpp:75