The ROme OpTimistic Simulator
3.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
mm.h
Go to the documentation of this file.
1
11
#pragma once
12
13
#include <
log/log.h
>
14
15
#include <stddef.h>
16
#include <stdlib.h>
17
26
inline
void
*
mm_alloc
(
size_t
mem_size)
27
{
28
void
*ret = malloc(mem_size);
29
30
if
(__builtin_expect(mem_size && !ret, 0)) {
31
log_log
(
LOG_FATAL
,
"Out of memory!"
);
32
abort();
// TODO: this can be criticized as xmalloc() in gcc. We shall dump partial stats before.
33
}
34
return
ret;
35
}
36
46
inline
void
*
mm_realloc
(
void
*ptr,
size_t
mem_size)
47
{
48
void
*ret = realloc(ptr, mem_size);
49
50
if
(__builtin_expect(mem_size && !ret, 0)) {
51
log_log
(
LOG_FATAL
,
"Out of memory!"
);
52
abort();
// TODO: this can be criticized as xmalloc() in gcc. We shall dump partial stats before.
53
}
54
return
ret;
55
}
56
61
inline
void
mm_free
(
void
*ptr)
62
{
63
free(ptr);
64
}
mm_realloc
void * mm_realloc(void *ptr, size_t mem_size)
A version of the stdlib realloc() used internally.
Definition:
mm.h:46
mm_free
void mm_free(void *ptr)
A version of the stdlib free() used internally.
Definition:
mm.h:61
log_log
#define log_log(lvl,...)
Produces a log.
Definition:
log.h:49
LOG_FATAL
#define LOG_FATAL
The logging level reserved to unexpected, fatal conditions.
Definition:
log.h:35
mm_alloc
void * mm_alloc(size_t mem_size)
A version of the stdlib malloc() used internally.
Definition:
mm.h:26
log.h
Logging library.
src
mm
mm.h
Generated by
1.8.17