Add further attributes that give the compiler a hint how large the returned pointers might be.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-03-11 11:58:10 +01:00
parent 40b21680df
commit 671ca07d23
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -166,7 +166,7 @@ char* __attribute__((malloc)) FTLstrdup(const char *src, const char * file, cons
}
#undef calloc
void* __attribute__((malloc)) FTLcalloc(size_t nmemb, size_t size, const char * file, const char * function, int line)
void* __attribute__((malloc)) __attribute__((alloc_size(1,2))) FTLcalloc(size_t nmemb, size_t size, const char * file, const char * function, int line)
{
// The FTLcalloc() function allocates memory for an array of nmemb elements
// of size bytes each and returns a pointer to the allocated memory. The
@@ -182,7 +182,7 @@ void* __attribute__((malloc)) FTLcalloc(size_t nmemb, size_t size, const char *
}
#undef realloc
void *FTLrealloc(void *ptr_in, size_t size, const char * file, const char * function, int line)
void __attribute__((alloc_size(2))) *FTLrealloc(void *ptr_in, size_t size, const char * file, const char * function, int line)
{
// The FTLrealloc() function changes the size of the memory block pointed to
// by ptr to size bytes. The contents will be unchanged in the range from
+2 -2
View File
@@ -94,8 +94,8 @@ void SQLite3LogCallback(void *pArg, int iErrCode, const char *zMsg);
// memory.c
void memory_check(int which);
char *FTLstrdup(const char *src, const char *file, const char *function, int line) __attribute__((malloc));
void *FTLcalloc(size_t nmemb, size_t size, const char *file, const char *function, int line) __attribute__((malloc));
void *FTLrealloc(void *ptr_in, size_t size, const char *file, const char *function, int line);
void *FTLcalloc(size_t nmemb, size_t size, const char *file, const char *function, int line) __attribute__((malloc)) __attribute__((alloc_size(1,2)));
void *FTLrealloc(void *ptr_in, size_t size, const char *file, const char *function, int line) __attribute__((alloc_size(2)));
void FTLfree(void *ptr, const char* file, const char *function, int line);
void validate_access(const char * name, int pos, bool testmagic, int line, const char * function, const char * file);