Mercurial > trustbridge
comparison common/listutil.c @ 86:6f1a73575c99
Check input parameters
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 20 Mar 2014 16:23:02 +0000 |
parents | 8ffbb48528ae |
children | 00f9b91f4039 |
comparison
equal
deleted
inserted
replaced
85:e52df5870c4f | 86:6f1a73575c99 |
---|---|
38 */ | 38 */ |
39 #define READ_FILE_UNREADABLE -1 | 39 #define READ_FILE_UNREADABLE -1 |
40 #define READ_FILE_TOO_LARGE -2 | 40 #define READ_FILE_TOO_LARGE -2 |
41 #define READ_FILE_NO_MEMORY -3 | 41 #define READ_FILE_NO_MEMORY -3 |
42 #define READ_FILE_READ_FAILED -4 | 42 #define READ_FILE_READ_FAILED -4 |
43 #define READ_FILE_INVALID_CALL -5 | |
43 static int read_file(const char *file_name, char **data, size_t *size, | 44 static int read_file(const char *file_name, char **data, size_t *size, |
44 const size_t max_size) | 45 const size_t max_size) |
45 { | 46 { |
46 FILE *f; | 47 FILE *f; |
47 long file_size; | 48 long file_size; |
49 | |
50 if (!file_name || !data || !size || !max_size) { | |
51 return READ_FILE_INVALID_CALL; | |
52 } | |
48 | 53 |
49 f = fopen(file_name, "rb"); | 54 f = fopen(file_name, "rb"); |
50 if (f == NULL) | 55 if (f == NULL) |
51 return READ_FILE_UNREADABLE; | 56 return READ_FILE_UNREADABLE; |
52 | 57 |