diff options
Diffstat (limited to 'src/allocator.h')
-rw-r--r-- | src/allocator.h | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/allocator.h b/src/allocator.h index e074b4ac..433ce85f 100644 --- a/src/allocator.h +++ b/src/allocator.h @@ -14,76 +14,76 @@ * limitations under the License. */ -#ifndef WASM_ALLOCATOR_H_ -#define WASM_ALLOCATOR_H_ +#ifndef WABT_ALLOCATOR_H_ +#define WABT_ALLOCATOR_H_ #include <stdlib.h> #include <string.h> #include "common.h" -#define WASM_DEFAULT_ALIGN sizeof(void*) +#define WABT_DEFAULT_ALIGN sizeof(void*) -typedef void* WasmAllocatorMark; +typedef void* WabtAllocatorMark; -typedef struct WasmAllocator { - void* (*alloc)(struct WasmAllocator*, +typedef struct WabtAllocator { + void* (*alloc)(struct WabtAllocator*, size_t size, size_t align, const char* file, int line); - void* (*realloc)(struct WasmAllocator*, + void* (*realloc)(struct WabtAllocator*, void* p, size_t size, size_t align, const char* file, int line); - void (*free)(struct WasmAllocator*, void* p, const char* file, int line); + void (*free)(struct WabtAllocator*, void* p, const char* file, int line); /* destroy the allocator */ - void (*destroy)(struct WasmAllocator*); + void (*destroy)(struct WabtAllocator*); /* mark/reset_to_mark are only supported by the stack allocator */ - WasmAllocatorMark (*mark)(struct WasmAllocator*); - void (*reset_to_mark)(struct WasmAllocator*, WasmAllocatorMark); - void (*print_stats)(struct WasmAllocator*); + WabtAllocatorMark (*mark)(struct WabtAllocator*); + void (*reset_to_mark)(struct WabtAllocator*, WabtAllocatorMark); + void (*print_stats)(struct WabtAllocator*); /* set the location to longjmp to if allocation fails. the return value is 0 * for normal execution, and 1 if an allocation failed. */ - int (*setjmp_handler)(struct WasmAllocator*); -} WasmAllocator; + int (*setjmp_handler)(struct WabtAllocator*); +} WabtAllocator; -extern WasmAllocator g_wasm_libc_allocator; +extern WabtAllocator g_wabt_libc_allocator; -#define wasm_alloc(allocator, size, align) \ +#define wabt_alloc(allocator, size, align) \ (allocator)->alloc((allocator), (size), (align), __FILE__, __LINE__) -#define wasm_alloc_zero(allocator, size, align) \ - wasm_alloc_zero_((allocator), (size), (align), __FILE__, __LINE__) +#define wabt_alloc_zero(allocator, size, align) \ + wabt_alloc_zero_((allocator), (size), (align), __FILE__, __LINE__) -#define wasm_realloc(allocator, p, size, align) \ +#define wabt_realloc(allocator, p, size, align) \ (allocator)->realloc((allocator), (p), (size), (align), __FILE__, __LINE__) -#define wasm_free(allocator, p) \ +#define wabt_free(allocator, p) \ (allocator)->free((allocator), (p), __FILE__, __LINE__) -#define wasm_destroy_allocator(allocator) (allocator)->destroy(allocator) -#define wasm_mark(allocator) (allocator)->mark(allocator) +#define wabt_destroy_allocator(allocator) (allocator)->destroy(allocator) +#define wabt_mark(allocator) (allocator)->mark(allocator) -#define wasm_reset_to_mark(allocator, mark) \ +#define wabt_reset_to_mark(allocator, mark) \ (allocator)->reset_to_mark(allocator, mark) -#define wasm_print_allocator_stats(allocator) \ +#define wabt_print_allocator_stats(allocator) \ (allocator)->print_stats(allocator) -#define wasm_strndup(allocator, s, len) \ - wasm_strndup_(allocator, s, len, __FILE__, __LINE__) +#define wabt_strndup(allocator, s, len) \ + wabt_strndup_(allocator, s, len, __FILE__, __LINE__) -#define wasm_dup_string_slice(allocator, str) \ - wasm_dup_string_slice_(allocator, str, __FILE__, __LINE__) +#define wabt_dup_string_slice(allocator, str) \ + wabt_dup_string_slice_(allocator, str, __FILE__, __LINE__) -WASM_EXTERN_C_BEGIN +WABT_EXTERN_C_BEGIN -WasmAllocator* wasm_get_libc_allocator(void); +WabtAllocator* wabt_get_libc_allocator(void); -static WASM_INLINE void* wasm_alloc_zero_(WasmAllocator* allocator, +static WABT_INLINE void* wabt_alloc_zero_(WabtAllocator* allocator, size_t size, size_t align, const char* file, @@ -93,7 +93,7 @@ static WASM_INLINE void* wasm_alloc_zero_(WasmAllocator* allocator, return result; } -static WASM_INLINE char* wasm_strndup_(WasmAllocator* allocator, +static WABT_INLINE char* wabt_strndup_(WabtAllocator* allocator, const char* s, size_t len, const char* file, @@ -111,17 +111,17 @@ static WASM_INLINE char* wasm_strndup_(WasmAllocator* allocator, return new_s; } -static WASM_INLINE WasmStringSlice -wasm_dup_string_slice_(WasmAllocator* allocator, - WasmStringSlice str, +static WABT_INLINE WabtStringSlice +wabt_dup_string_slice_(WabtAllocator* allocator, + WabtStringSlice str, const char* file, int line) { - WasmStringSlice result; - result.start = wasm_strndup_(allocator, str.start, str.length, file, line); + WabtStringSlice result; + result.start = wabt_strndup_(allocator, str.start, str.length, file, line); result.length = str.length; return result; } -WASM_EXTERN_C_END +WABT_EXTERN_C_END -#endif /* WASM_ALLOCATOR_H_ */ +#endif /* WABT_ALLOCATOR_H_ */ |