ZEDA  1.6.18
Macros | Functions
dynamic memory allocation.

Macros

#define zAlloc(t, n)   ( (n) == 0 ? NULL : (t *)calloc( (n), sizeof(t) ) )
 
#define zAllocZero(t, n)   ( (n) == 0 ? NULL : (t *)calloc( (n), sizeof(t) ) )
 
#define zFree(m)   do{ if( (m) ){ free( m ); (m) = NULL; } } while(0)
 
#define zCopy(t, s, d)   ( (t *)memcpy( d, s, sizeof(t) ) )
 
#define zRealloc(m, t, n)   (t *)realloc( (void *)m, sizeof(t)*(n) )
 

Functions

void * zClone (void *src, size_t size)
 clone a memory space. More...
 

Detailed Description

Macro Definition Documentation

◆ zAlloc

#define zAlloc (   t,
 
)    ( (n) == 0 ? NULL : (t *)calloc( (n), sizeof(t) ) )

allocate memory for n data of a data type type.

◆ zAllocZero

#define zAllocZero (   t,
 
)    ( (n) == 0 ? NULL : (t *)calloc( (n), sizeof(t) ) )

allocate memory for n data of a data type type and clear it by zero.

◆ zFree

#define zFree (   m)    do{ if( (m) ){ free( m ); (m) = NULL; } } while(0)

free memory allocated at m. m is reset to be the null pointer after freeing the memory.

◆ zCopy

#define zCopy (   t,
  s,
 
)    ( (t *)memcpy( d, s, sizeof(t) ) )

copy s to d, where both are supposed to be types of t.

◆ zRealloc

#define zRealloc (   m,
  t,
 
)    (t *)realloc( (void *)m, sizeof(t)*(n) )

reallocate memory where m points. n is the number of data to be reallocated. type is the type of the data.

Note
zRealloc() is not available in the kernel space.

Function Documentation

◆ zClone()

void* zClone ( void *  src,
size_t  size 
)

clone a memory space.

zClone() clones a memory space src with a size size and returns a pointer to the newly allocated memory if succeeding. Otherwise, the null pointer is returned.