pntr
Image manipulation library
Memory

Macros

#define PNTR_MALLOC(size)   malloc(size)
 
#define PNTR_FREE(ptr)   free(ptr)
 
#define PNTR_REALLOC(ptr, new_size)   realloc(ptr, new_size)
 
#define PNTR_MEMCPY(dest, src, n)   memcpy(dest, src, n)
 
#define PNTR_MEMSET(str, c, n)   memset((str), (c), (n))
 

Detailed Description

Macro Definition Documentation

◆ PNTR_FREE

#define PNTR_FREE (   ptr)    free(ptr)

Deallocates the previously allocated memory.

Parameters
ptr(void*) pointer to the memory to deallocate
See also
PNTR_MALLOC
https://en.cppreference.com/w/c/memory/free

◆ PNTR_MALLOC

#define PNTR_MALLOC (   size)    malloc(size)

Allocates the requested memory and returns a pointer to it.

Parameters
size(size_t) number of bytes to allocate
Returns
On success, returns the pointer to the beginning of newly allocated memory.
See also
PNTR_FREE
https://en.cppreference.com/w/c/memory/malloc

◆ PNTR_MEMCPY

#define PNTR_MEMCPY (   dest,
  src,
 
)    memcpy(dest, src, n)

Copies data from memory area src to the destination memory.

Parameters
dest(void*) pointer to the object to copy to
src(const void*) pointer to the object to copy from
n(size_t) number of bytes to copy
See also
https://en.cppreference.com/w/c/string/byte/memcpy

◆ PNTR_MEMSET

#define PNTR_MEMSET (   str,
  c,
 
)    memset((str), (c), (n))

Copies the character c (an unsigned char) to the first n characters of the string pointed to, by the argument str.

◆ PNTR_REALLOC

#define PNTR_REALLOC (   ptr,
  new_size 
)    realloc(ptr, new_size)

Attempts to resize the memory block pointed to that was previously allocated.

Parameters
ptr(void*) pointer to the memory area to be reallocated
new_size(size_t) new size of the array in bytes
Returns
On success, returns the pointer to the beginning of newly allocated memory. To avoid a memory leak, the returned pointer must be deallocated with free or realloc. The original pointer ptr is invalidated and any access to it is undefined behavior (even if reallocation was in-place).
See also
https://en.cppreference.com/w/c/memory/realloc