Nilorea Library

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
Macros | Functions
n_misc.h File Reference
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <strings.h>`
`#include <sysexits.h>`
`#include "n_log.h"`
Include dependency graph for n_misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | Malloc(__ptr, __struct, __size)
#define | Malloc_s(__ptr, __struct, __size)
#define | Free(__ptr)
#define | FreeNoLog(__ptr)

## Functions

void | usage (char *name)
| Print program commands. More...
char ** | split (char *chaine, const char *delim, int vide)
| Split the strings into a an array of char *pointer ended by a NULL one. Max 256 splitted elements per call. More...
int | free_split_result (char ***tab)
| Free a split result allocated array. More...

## Macro Definition Documentation

#define Free | ( |  | __ptr | ) |

Value:
do \
{ \
if ( __ptr )\
{\
free( __ptr );\
__ptr = NULL;\
}\
else\
{\
log( DEBUG ,"Free( %s ) already done or NULL", #__ptr );\
} \
}while( 0 )

Free handler

Definition at line 71 of file n_misc.h.

#define FreeNoLog | ( |  | __ptr | ) |

Value:
do \
{ \
if ( __ptr )\
{\
free( __ptr );\
__ptr = NULL;\
}\
}while( 0 )

Free handler without logging

Definition at line 89 of file n_misc.h.

#define Malloc | ( |  | __ptr,
|  |  | __struct,
|  |  | __size
| ) |  |

Value:
do \
{ \
if ( !( __ptr = ( __struct *)calloc( __size , sizeof( __struct ) ) ) ) \
{ \
log( ERROR , "( %s *)malloc( %s * sizeof( %d ) ) Error !", #__ptr , #__struct , __size ); \
exit( -1 ); \
} \
} while( 0 )

TRUE !

FALSE !

calloc Handler. Set pointer to NULL on error.

Definition at line 40 of file n_misc.h.

#define Malloc_s | ( |  | __ptr,
|  |  | __struct,
|  |  | __size
| ) |  |

Value:
do \
{ \
if ( !( __ptr = ( __struct *)calloc( __size , sizeof( __struct ) ) ) ) \
{ \
log( ERROR , "( %s *)malloc( %s * sizeof( %d ) ) Error !", #__ptr , #__struct , __size ); \
__ptr = NULL ; \
exit( EX_OSERR ); \
} \
} while( 0 )

calloc Handler. Set pointer to NULL and exit on error.

Definition at line 55 of file n_misc.h.

## Function Documentation

int free_split_result | ( | char *** | tab | ) |

Free a split result allocated array.

Parameters

  tab | A pointer to a split result to free

Returns
  TRUE

Definition at line 124 of file n_misc.c.

split | ( | char * | chaine,
|  | const char * | delim,
|  | int | vide
| ) |  |

Split the strings into a an array of char *pointer ended by a NULL one. Max 256 splitted elements per call.

Split the strings into a an array of char *pointer , ended by a NULL one. Max 256 splitted elements per call.

Returns
  An array of strings to the new string.

Definition at line 39 of file n_misc.c.

void usage | ( | char * | name | ) |

Print program commands.

void usage( char *name )

Parameters

  name | program name to print in command usage

Definition at line 22 of file n_misc.c.