|
| 1 | +#ifndef windows_h |
| 2 | +#include <windows.h> |
| 3 | +#endif |
| 4 | + |
| 5 | +// Creates a new dynamic array. Each element of the array has size of sizeof_type. |
| 6 | +// Returns a handle to the array. |
| 7 | +int __cdecl darr_new(int sizeof_type); |
| 8 | +API(darr_new,DynamicArray) |
| 9 | + |
| 10 | +// Returns the size of the dynamic array, in number of elements, |
| 11 | +// or zero if the handle does not exist. |
| 12 | +int __cdecl darr_size(int handle); |
| 13 | +API(darr_size,DynamicArray) |
| 14 | + |
| 15 | +// Returns the size of each individual element, |
| 16 | +// or zero if the handle does not exist. |
| 17 | +int __cdecl darr_typesize(int handle); |
| 18 | +API(darr_typesize,DynamicArray) |
| 19 | + |
| 20 | +// Pushes the input element to the back of the dynamic array. |
| 21 | +// If the current |
| 22 | +// Returns the new size of the dynamic array, in number of elements, |
| 23 | +// or zero if the handle does not exist. |
| 24 | +int __cdecl darr_push_back(int handle, void* pElement); |
| 25 | +API(darr_push_back,DynamicArray) |
| 26 | + |
| 27 | +// Returns a (temporary) pointer to element number nElement of the array, |
| 28 | +// or NULL if the handle does not exist. |
| 29 | +// The pointer should be assumed invalid once the array is resized or reserved. |
| 30 | +void* __cdecl darr_pointer(int handle, int nElement); |
| 31 | +API(darr_pointer,DynamicArray) |
| 32 | + |
| 33 | +// Resizes the array in terms of number of elements. |
| 34 | +// Behavior is similar to that of std::vector. |
| 35 | +// Returns true if completed, false if handle not recognized. |
| 36 | +bool __cdecl darr_resize(int handle, int nSize); |
| 37 | +API(darr_resize,DynamicArray) |
| 38 | + |
| 39 | +// Pre-allocates contiguous memory without changing the size of the dynamic array. |
| 40 | +// Behavior is similar to that of std::vector. |
| 41 | +// Returns true if completed, false if handle not recognized. |
| 42 | +bool __cdecl darr_reserve(int handle, int nSize); |
| 43 | +API(darr_reserve,DynamicArray) |
| 44 | + |
| 45 | +// De-allocates the dynamic vector from memory |
| 46 | +// After this function, the handle will no longer be recognized. |
| 47 | +// Returns true if completed, false if handle not recognized. |
| 48 | +bool __cdecl darr_destroy(int handle); |
| 49 | +API(darr_destroy,DynamicArray) |
0 commit comments