Commit 3e8927a
authored
Adding option to pass user data to allocator functions (#1765)
Add an option to pass user data to the allocator functions. It is common to
do this so that the host embedder can pass a struct as user data and access
that struct from the allocator, which gives the host embedder the ability to
do things such as track allocation statistics within the allocator.
Compile with `cmake -DWASM_MEM_ALLOC_WITH_USER_DATA=1` to enable
the option, and the allocator functions provided by the host embedder should
be like below (an extra argument `data` is added):
void *malloc(void *data, uint32 size) { .. }
void *realloc(void *data, uint32 size) { .. }
void free(void *data, void *ptr) { .. }
Signed-off-by: Andrew Chambers <[email protected]>1 parent 216b2cb commit 3e8927a
File tree
6 files changed
+88
-9
lines changed- build-scripts
- core
- iwasm
- common
- include
6 files changed
+88
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
429 | 433 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
343 | 347 | | |
344 | 348 | | |
345 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| 32 | + | |
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
| |||
39 | 48 | | |
40 | 49 | | |
41 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
42 | 69 | | |
43 | 70 | | |
44 | 71 | | |
| |||
54 | 81 | | |
55 | 82 | | |
56 | 83 | | |
| 84 | + | |
57 | 85 | | |
58 | 86 | | |
59 | 87 | | |
60 | 88 | | |
61 | 89 | | |
62 | | - | |
| 90 | + | |
63 | 91 | | |
64 | 92 | | |
65 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
66 | 96 | | |
| 97 | + | |
67 | 98 | | |
68 | 99 | | |
69 | 100 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
73 | 113 | | |
| 114 | + | |
74 | 115 | | |
75 | 116 | | |
76 | 117 | | |
| |||
110 | 151 | | |
111 | 152 | | |
112 | 153 | | |
113 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
114 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
115 | 163 | | |
116 | 164 | | |
117 | 165 | | |
| |||
126 | 174 | | |
127 | 175 | | |
128 | 176 | | |
129 | | - | |
| 177 | + | |
130 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
131 | 182 | | |
| 183 | + | |
132 | 184 | | |
133 | 185 | | |
134 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
135 | 190 | | |
136 | 191 | | |
137 | 192 | | |
| |||
152 | 207 | | |
153 | 208 | | |
154 | 209 | | |
155 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
156 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
157 | 219 | | |
158 | 220 | | |
159 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| |||
0 commit comments