spBase
Loading...
Searching...
No Matches
Memory Management

Macros

#define xspAlloc(n, type)   (type *)xspMalloc((int)(n)*sizeof(type))
 
#define xspRealloc(p, n, type)   (type *)xspRemalloc((char *)(p), (int)(n)*sizeof(type))
 
#define xspFree(p)   {_xspFree((char *)(p)); (p) = NULL;}
 
#define spArrayCopy(p1, p2, n, type)   memmove((char *)(p1), (char *)(p2), (unsigned)(n)*sizeof(type))
 
#define xalloc(n, type)   xspAlloc(n, type)
 
#define xrealloc(p, n, type)   xspRealloc(p, n, type)
 
#define xfree(p)   xspFree(p)
 
#define strclone(string)   xspStrClone(string)
 
#define arrcpy(p1, p2, n, type)   spArrayCopy(p1, p2, n, type)
 

Functions

char * xspMalloc (int nbytes)
 
char * xspRemalloc (char *p, int nbytes)
 
void _xspFree (char *p)
 
int ** xspIMatAlloc (int row, int col)
 
void xspIMatFree (int **mat, int row)
 
short ** xspSMatAlloc (int row, int col)
 
void xspSMatFree (short **mat, int row)
 
long ** xspLMatAlloc (int row, int col)
 
void xspLMatFree (long **mat, int row)
 
float ** xspFMatAlloc (int row, int col)
 
void xspFMatFree (float **mat, int row)
 
double ** xspDMatAlloc (int row, int col)
 
void xspDMatFree (double **mat, int row)
 
char ** xspCMatAlloc (int row, int col)
 
void xspCMatFree (char **mat, int row)
 
unsigned char ** xspUCMatAlloc (int row, int col)
 
void xspUCMatFree (unsigned char **mat, int row)
 
char * xspStrClone (const char *string)
 

Detailed Description

Macro Definition Documentation

◆ xspAlloc

#define xspAlloc ( n,
type )   (type *)xspMalloc((int)(n)*sizeof(type))

Macro to allocate memory.

◆ xspRealloc

#define xspRealloc ( p,
n,
type )   (type *)xspRemalloc((char *)(p), (int)(n)*sizeof(type))

Macro to resize the allocated memory block.

◆ xspFree

#define xspFree ( p)    {_xspFree((char *)(p)); (p) = NULL;}

Macro to free the allocated memory block.

Examples
dirtest.c.

◆ spArrayCopy

#define spArrayCopy ( p1,
p2,
n,
type )   memmove((char *)(p1), (char *)(p2), (unsigned)(n)*sizeof(type))

Macro to copy the array contents of p2 to the address of p1 .

◆ xalloc

#define xalloc ( n,
type )   xspAlloc(n, type)

Macro to allocate memory (abbreviated version).

◆ xrealloc

#define xrealloc ( p,
n,
type )   xspRealloc(p, n, type)

Macro to resize the allocated memory block (abbreviated version).

◆ xfree

#define xfree ( p)    xspFree(p)

Macro to free the allocated memory block (abbreviated version).

◆ strclone

#define strclone ( string)    xspStrClone(string)

Makes a memory-allocated clone of the string specified by string (abbreviated version).

◆ arrcpy

#define arrcpy ( p1,
p2,
n,
type )   spArrayCopy(p1, p2, n, type)

Macro to copy the array contents of p2 to the address of p1 (abbreviated version).

Function Documentation

◆ xspMalloc()

char * xspMalloc ( int nbytes)
extern

Allocates memory.

◆ xspRemalloc()

char * xspRemalloc ( char * p,
int nbytes )
extern

Resize the allocated memory block.

◆ _xspFree()

void _xspFree ( char * p)
extern

Frees memory. Use xspFree() instead of this function.

◆ xspIMatAlloc()

int ** xspIMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of int type.

◆ xspIMatFree()

void xspIMatFree ( int ** mat,
int row )
extern

Frees memory of a 2-d array of int type.

◆ xspSMatAlloc()

short ** xspSMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of short type.

◆ xspSMatFree()

void xspSMatFree ( short ** mat,
int row )
extern

Frees memory of a 2-d array of short type.

◆ xspLMatAlloc()

long ** xspLMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of long type.

◆ xspLMatFree()

void xspLMatFree ( long ** mat,
int row )
extern

Frees memory of a 2-d array of long type.

◆ xspFMatAlloc()

float ** xspFMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of float type.

◆ xspFMatFree()

void xspFMatFree ( float ** mat,
int row )
extern

Frees memory of a 2-d array of float type.

◆ xspDMatAlloc()

double ** xspDMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of double type.

◆ xspDMatFree()

void xspDMatFree ( double ** mat,
int row )
extern

Frees memory of a 2-d array of double type.

◆ xspCMatAlloc()

char ** xspCMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of char type.

◆ xspCMatFree()

void xspCMatFree ( char ** mat,
int row )
extern

Frees memory of a 2-d array of char type.

◆ xspUCMatAlloc()

unsigned char ** xspUCMatAlloc ( int row,
int col )
extern

Allocates memory for a 2-d array of unsigned char type.

◆ xspUCMatFree()

void xspUCMatFree ( unsigned char ** mat,
int row )
extern

Frees memory of a 2-d array of unsigned char type.

◆ xspStrClone()

char * xspStrClone ( const char * string)
extern

Makes a memory-allocated clone of the string specified by string .