image.c: use MAX
This commit is contained in:
parent
aec66da3b1
commit
556189ee3a
10
src/image.c
10
src/image.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user