-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.json
77 lines (77 loc) · 2.79 KB
/
docs.json
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[
{
"kind": "module",
"file": "source\\bc\\memory\\allocator.d",
"members": [
{
"kind": "struct",
"line": 53,
"char": 1,
"members": [
{
"parameters": [
{
"deco": "m",
"name": "size"
}
],
"line": 63,
"kind": "function",
"originalType": "void*(size_t size)",
"char": 11,
"name": "malloc",
"deco": "FmZPv",
"endchar": 5,
"endline": 69,
"comment": "\tAllocate memory\n\tParams: size = Size in bytes of memory to be allocated\n\tReturns: Pointer to new allocated memory\n"
},
{
"parameters": [
{
"deco": "m",
"name": "size"
}
],
"line": 76,
"kind": "function",
"originalType": "void*(size_t size)",
"char": 11,
"name": "calloc",
"deco": "FmZPv",
"endchar": 5,
"endline": 82,
"comment": "\tAllocate zeroed memory\n\tParams: size = Size in bytes of memory to be allocated\n\tReturns: Pointer to new allocated memory\n"
},
{
"parameters": [
{
"deco": "Pv",
"name": "ptr"
}
],
"line": 88,
"kind": "function",
"char": 10,
"name": "free",
"deco": "FPvZv",
"endchar": 5,
"endline": 93,
"comment": "\tFree memory\n\tParams: ptr = Pointer to the memory address to be freed\n"
}
],
"comment": "\tBasic Default Allocator\n",
"name": "DefaultAllocator"
},
{
"kind": "variable",
"line": 97,
"char": 18,
"deco": "S2bc6memory9allocator16DefaultAllocator",
"comment": "global variable that are used by default on implementations that require an allocator.\n",
"name": "default_alloc"
}
],
"comment": "\tThis module provides a basic allocator that implements `malloc, calloc and free.`\n\n\tAlso set a global variable called `default_alloc` that is used as the default allocator for\n\tall the lib.\n\n\tA basic allocator must have this signature:\n\t---\nstruct IAllocator\n{\n\tvoid* malloc(size_t);\n\tvoid* calloc(size_t);\n\tvoid free(void*);\n}\n\t---\nExample:\n$(DDOX_UNITTEST_HEADER __unittest_L20_C1)\n---\nstruct LogAllocator\n{\n \timport core.stdc.stdlib : \n \t\t_malloc = malloc,\n \t\t_calloc = calloc,\n \t\t_free = free;\n\timport core.stdc.stdio : printf;\n\n\tvoid* malloc(size_t size ){\n\t\tprintf(\"Malloc : (%d)\\n\", size);\n\t\treturn _malloc( size );\n\t}\n\tvoid* calloc(size_t size){\n\t\tprintf(\"Calloc : (%d)\\n\", size);\n\t\treturn _calloc( size );\n\t}\n\tvoid free(void* ptr){\n\t\t_free(ptr);\n\t\tprintf(\"Free : (%p)\\n\", ptr);\n\t}\n}\n\nauto log_allocator = LogAllocator();\nauto buffer = log_allocator.malloc(100);\nlog_allocator.free(buffer);\n\n---\n$(DDOX_UNITTEST_FOOTER __unittest_L20_C1)\n",
"name": "bc.memory.allocator"
}
]