|
@@ -11,16 +11,14 @@
|
11
|
11
|
#include <stdio.h>
|
12
|
12
|
#include <string.h>
|
13
|
13
|
#include <stdarg.h>
|
|
14
|
+#include <assert.h>
|
14
|
15
|
|
15
|
16
|
#include "utils/tga.h"
|
16
|
17
|
|
17
|
18
|
int tgaCheck(FILE *f) {
|
18
|
19
|
char buffer[10];
|
19
|
20
|
|
20
|
|
- if (!f) {
|
21
|
|
- perror("tgaCheck> Passed invalid file.\n");
|
22
|
|
- return -1;
|
23
|
|
- }
|
|
21
|
+ assert(f != NULL);
|
24
|
22
|
|
25
|
23
|
/* Read the header */
|
26
|
24
|
fseek(f, 0, SEEK_SET);
|
|
@@ -46,10 +44,11 @@ int tgaLoad(FILE *f, unsigned char **image, unsigned int *width, unsigned int *h
|
46
|
44
|
unsigned int size;
|
47
|
45
|
unsigned int i, j;
|
48
|
46
|
|
49
|
|
- if (!f) {
|
50
|
|
- fprintf(stderr, "tgaLoad> Invalid parameters.\n");
|
51
|
|
- return -1;
|
52
|
|
- }
|
|
47
|
+ assert(f != NULL);
|
|
48
|
+ assert(image != NULL);
|
|
49
|
+ assert(width != NULL);
|
|
50
|
+ assert(height != NULL);
|
|
51
|
+ assert(type != NULL);
|
53
|
52
|
|
54
|
53
|
fseek(f, 0, SEEK_SET);
|
55
|
54
|
|
|
@@ -264,10 +263,10 @@ int tgaSave(FILE *f, unsigned char *image, unsigned int width, unsigned int heig
|
264
|
263
|
//unsigned int i;
|
265
|
264
|
//unsigned char tmp;
|
266
|
265
|
|
267
|
|
- if (!f || !image || !width || !height) {
|
268
|
|
- fprintf(stderr, "tgaSave> Invalid parameters.\n");
|
269
|
|
- return -1;
|
270
|
|
- }
|
|
266
|
+ assert(f != NULL);
|
|
267
|
+ assert(image != NULL);
|
|
268
|
+ assert(width > 0);
|
|
269
|
+ assert(height > 0);
|
271
|
270
|
|
272
|
271
|
strncpy(comment, "OpenRaider TGA", 63);
|
273
|
272
|
comment[63] = 0;
|
|
@@ -361,6 +360,12 @@ int tgaSaveFilename(unsigned char *image, unsigned int width, unsigned int heigh
|
361
|
360
|
FILE *f;
|
362
|
361
|
int v;
|
363
|
362
|
va_list args;
|
|
363
|
+
|
|
364
|
+ assert(image != NULL);
|
|
365
|
+ assert(width > 0);
|
|
366
|
+ assert(height > 0);
|
|
367
|
+ assert(s != NULL);
|
|
368
|
+
|
364
|
369
|
va_start(args, s);
|
365
|
370
|
vsnprintf(buffer, 1023, s, args);
|
366
|
371
|
va_end(args);
|