总是记不住内存相关函数的API,特此记录。
1. malloc
void* malloc (size_t size);
Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
2. free
void free (void* ptr);
A block of memory previously allocated by a call to malloc, calloc or realloc is deallocated, making it available again for further allocations.
If ptr does not point to a block of memory allocated with the above functions, it causes undefined behavior.
If ptr is a null pointer, the function does nothing.
3. memcpy
void * memcpy ( void * destination, const void * source, size_t num );
Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination.
4. memmove
void * memmove ( void * destination, const void * source, size_t num );
Copies the values of num bytes from the location pointed by source to the memory block pointed by destination. Copying takes place as if an intermediate buffer were used, allowing the destination and source to overlap.