![]() |
Toy 1.1.6
The Toy programming language is an imperative bytecode-intermediate embedded scripting language
|
@???@ More...
Go to the source code of this file.
Macros | |
| #define | TOY_GROW_CAPACITY(capacity) ((capacity) < 8 ? 8 : (capacity) * 2) |
| calculates, in place, what size of memory should be allocated based on the previous size. | |
| #define | TOY_GROW_CAPACITY_FAST(capacity) ((capacity) < 32 ? 32 : (capacity) * 2) |
| Calculates, in place, what size of memory should be allocated based on the previous size. It grows faster than TOY_GROW_CAPACITY. | |
| #define | TOY_ALLOCATE(type, count) ((type*)Toy_reallocate(NULL, 0, sizeof(type) * (count))) |
| Wraps Toy_reallocate, which itself calls the allocator function. type is the type that will be allocated, and count is the number which will be needed (usually calculated with TOY_GROW_CAPACITY). returns a pointer of type. | |
| #define | TOY_FREE(type, pointer) Toy_reallocate(pointer, sizeof(type), 0) |
| Wraps Toy_reallocate, which itself calls the allocator function. type is the type that will be freed, and pointer is to what is being freed. This should only be used when a single element has been allocated, as opposed to an array. | |
| #define | TOY_FREE_ARRAY(type, pointer, oldCount) Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), 0) |
| Wraps Toy_reallocate, which itself calls the allocator function. type is the type that will be freed, pointer is a reference to what is being freed, and oldCount is the size of the array being freed. This should only be used when an array has been allocated, as opposed to a single element. | |
| #define | TOY_GROW_ARRAY(type, pointer, oldCount, count) (type*)Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count)) |
| Wraps Toy_reallocate, which itself calls the allocator function. type is the type that is being operated on, pointer is what is being resized, oldCount is the previous size of the array and count is the new size of the array (usually calculated with TOY_GROW_CAPACITY). | |
| #define | TOY_SHRINK_ARRAY(type, pointer, oldCount, count) (type*)Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count)) |
| Wraps Toy_reallocate, which itself calls the allocator function. type is the type that is being operated on, pointer is what is being resized, oldCount is the previous size of the array and count is the new size of the array. This returns a pointer of type. | |
Typedefs | |
| typedef void *(* | Toy_MemoryAllocatorFn) (void *pointer, size_t oldSize, size_t newSize) |
| This function interface is used for defining any memory allocator functions. Any and all memory allocator functions should: | |
Functions | |
| TOY_API void * | Toy_reallocate (void *pointer, size_t oldSize, size_t newSize) |
| Wraps a call to the internal assigned memory allocator. This function shouldn't be called directly. Instead, use one of the given macros. | |
| TOY_API void | Toy_setMemoryAllocator (Toy_MemoryAllocatorFn) |
| Sets the memory allocator, replacing the default memory allocator. This function also overwrites any given refstring memory allocator, see toy_refstring.h. | |
@???@
| #define TOY_ALLOCATE | ( | type, | |
| count | |||
| ) | ((type*)Toy_reallocate(NULL, 0, sizeof(type) * (count))) |
Wraps Toy_reallocate, which itself calls the allocator function. type is the type that will be allocated, and count is the number which will be needed (usually calculated with TOY_GROW_CAPACITY). returns a pointer of type.
| #define TOY_FREE | ( | type, | |
| pointer | |||
| ) | Toy_reallocate(pointer, sizeof(type), 0) |
Wraps Toy_reallocate, which itself calls the allocator function. type is the type that will be freed, and pointer is to what is being freed. This should only be used when a single element has been allocated, as opposed to an array.
| #define TOY_FREE_ARRAY | ( | type, | |
| pointer, | |||
| oldCount | |||
| ) | Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), 0) |
Wraps Toy_reallocate, which itself calls the allocator function. type is the type that will be freed, pointer is a reference to what is being freed, and oldCount is the size of the array being freed. This should only be used when an array has been allocated, as opposed to a single element.
| #define TOY_GROW_ARRAY | ( | type, | |
| pointer, | |||
| oldCount, | |||
| count | |||
| ) | (type*)Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count)) |
Wraps Toy_reallocate, which itself calls the allocator function. type is the type that is being operated on, pointer is what is being resized, oldCount is the previous size of the array and count is the new size of the array (usually calculated with TOY_GROW_CAPACITY).
| #define TOY_GROW_CAPACITY | ( | capacity | ) | ((capacity) < 8 ? 8 : (capacity) * 2) |
calculates, in place, what size of memory should be allocated based on the previous size.
| #define TOY_GROW_CAPACITY_FAST | ( | capacity | ) | ((capacity) < 32 ? 32 : (capacity) * 2) |
Calculates, in place, what size of memory should be allocated based on the previous size. It grows faster than TOY_GROW_CAPACITY.
| #define TOY_SHRINK_ARRAY | ( | type, | |
| pointer, | |||
| oldCount, | |||
| count | |||
| ) | (type*)Toy_reallocate((type*)pointer, sizeof(type) * (oldCount), sizeof(type) * (count)) |
Wraps Toy_reallocate, which itself calls the allocator function. type is the type that is being operated on, pointer is what is being resized, oldCount is the previous size of the array and count is the new size of the array. This returns a pointer of type.
| void *(* Toy_MemoryAllocatorFn)(void *pointer, size_t oldSize, size_t newSize) |
This function interface is used for defining any memory allocator functions. Any and all memory allocator functions should:
| pointer | |
| oldSize | |
| newSize |
| void * Toy_reallocate | ( | void * | pointer, |
| size_t | oldSize, | ||
| size_t | newSize | ||
| ) |
Wraps a call to the internal assigned memory allocator. This function shouldn't be called directly. Instead, use one of the given macros.
| pointer | |
| oldSize | |
| newSize |
| void Toy_setMemoryAllocator | ( | Toy_MemoryAllocatorFn | ) |
Sets the memory allocator, replacing the default memory allocator. This function also overwrites any given refstring memory allocator, see toy_refstring.h.
| Toy_MemoryAllocatorFn |