-
-
Notifications
You must be signed in to change notification settings - Fork 594
/
mem.d
51 lines (42 loc) · 1.39 KB
/
mem.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Copyright: Copyright (C) 1985-1998 by Symantec
* Copyright (C) 2000-2019 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/mem.d, backend/mem.d)
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/backend/mem.d
*/
module dmd.backend.mem;
import core.stdc.stdlib : malloc, calloc, realloc, free;
import core.stdc.string : strdup;
extern (C):
nothrow:
@nogc:
char* mem_strdup(const char* p) { return strdup(p); }
void* mem_malloc(size_t u) { return malloc(u); }
void* mem_fmalloc(size_t u) { return malloc(u); }
void* mem_calloc(size_t u) { return calloc(u, 1); }
void* mem_realloc(void* p, size_t u) { return realloc(p, u); }
void mem_free(void* p) { free(p); }
extern (C++)
{
void mem_free_cpp(void *);
alias mem_freefp = mem_free_cpp;
}
version (MEM_DEBUG)
{
alias mem_fstrdup = mem_strdup;
alias mem_fcalloc = mem_calloc;
alias mem_fmalloc = mem_malloc;
alias mem_ffree = mem_free;
}
else
{
char *mem_fstrdup(const(char) *);
void *mem_fcalloc(size_t);
void *mem_fmalloc(size_t);
void mem_ffree(void *) { }
}