image.c: use MAX

This commit is contained in:
Lennart Buhl 2013-11-02 23:14:08 +01:00
parent aec66da3b1
commit 556189ee3a
3 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h> // MAX
#include "image.h"
#define LINELEN 20000
char *readImage(const char* filename, int *cols, int *rows) {
FILE *f = fopen(filename, "r");
@ -11,7 +18,7 @@ char *readImage(const char* filename, int *cols, int *rows) {
if (!f) {
while (fgets(linebuf, LINELEN, f)) {
int len = strlen(linebuf);
*cols = len>*cols?len:*cols;
*cols = MAX(len, *cols);
(*rows)++;
}
@ -29,3 +36,4 @@ char *readImage(const char* filename, int *cols, int *rows) {
return ret;
}

View File

@ -1,12 +1,6 @@
#ifndef __IMAGE
#define __IMAGE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LINELEN 20000
char *readImage(const char* filename, int *cols, int *rows);
#endif