Memory(API)
From EosPedia
General/Memory is API for memory management.
Contents
constant
struct
typedef void* Memory;
API
Memory Allocation
#define MemoryAllocate(type,num,message) (type*)memoryAllocate(sizeof(type)*(num),message)
extern Memory memoryAllocate(size_t byte, char* message);
Release of memory
#define memoryFree(ptr) free(ptr)
Memory Copy as byte
Copy src to dst.
extern Memory memoryCopy(Memory dst, Memory src, size_t byte);
Allocate memory and Copy src to it.
extern Memory memoryDuplicate(Memory src, size_t byte);
Memory Clear
Data of src is overwritten at n.
extern Memory memoryClear(Memory src, size_t, char n);
Byte swap
Swap between 2 datas as byte. It is useful for converting Endian.
extern Memory memoryByteSwap(Memory src, size_t, int n);
Swap positions is different depending on size_t.
size_t | Description |
---|---|
1 | No swap |
2 | Swap 0th byte and 1st byte |
4 | Swap 0th byte and 3rd byte Swap 1st byte and 2nd byte |
8 | At n=0, ... , 3 Swap nth byte and (7-n)th byte |