]> git.neil.brown.name Git - edlib.git/blob - safe.h
TODO: clean out done items.
[edlib.git] / safe.h
1 /*
2  * Copyright Neil Brown ©2016-2020 <neil@brown.name>
3  * May be distributed under terms of GPLv2 - see file:COPYING
4  */
5 #ifndef __CHECK_SAFE__
6 #define __CHECK_SAFE__ 1
7 #ifdef __CHECKER__
8 #define safe __attribute__((safe))
9 #define safe_cast (void * safe)
10 extern void *safe calloc(int, int);
11 extern void *safe malloc(int);
12 extern void *safe realloc(void *, int);
13 extern char *safe strdup(const char *safe);
14 extern char *safe strndup(const char *safe, int);
15 extern int strcmp(const char *a safe, const char *b safe);
16 extern int strncmp(const char *a safe, const char *b safe, int n);
17 extern char *safe strcpy(char *a safe, const char *b safe);
18 extern char *safe strncpy(char *a safe, const char *b safe, int n);
19 extern char *safe strcat(char *a safe, const char *b safe);
20 extern char *safe strncat(char *a safe, const char *b safe, int n);
21 extern char *strchr(const char *a safe, char b);
22 extern char *safe strchrnul(const char *a safe, char b);
23 extern char *strrchr(const char *a safe, char b);
24 extern int strlen(const char *a safe);
25
26 extern const unsigned short int **safe __ctype_b_loc(void);
27 extern int *safe __errno_location(void);
28 #else
29 #define safe
30 #define safe_cast
31 #endif
32
33 #endif /* __CHECK_SAFE__ */