summaryrefslogtreecommitdiffstats
path: root/eurephia_nullsafe.h
blob: 66f8f81a2f933c8913eb492db8ba62117541cd51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
** eurephia_nullsafe.h
**
** standard C string functions, which is made NULL safe by checking 
** if input value is NULL before performing the action.
**
** 
*/

#ifndef   	EUREPHIA_NULLSAFE_H_
#define    	EUREPHIA_NULLSAFE_H_

#define atoi_nullsafe(str) (str != NULL ? atoi(str) : 0)
#define strdup_nullsafe(str) (str != NULL ? strdup(str) : NULL)
#define strlen_nullsafe(str) (str != NULL ? strlen(str) : 0)
#define free_nullsafe(str) if( str != NULL ) { free(str); str = NULL;}

#endif 	    /* !EUREPHIA_NULLSAFE_H_ */