From e5ff0119587f212a12161ff174c9ca4df0073826 Mon Sep 17 00:00:00 2001 From: Matteo Paonessa Date: Tue, 22 Sep 2015 20:03:02 +0200 Subject: [PATCH] Cleaning in the make process --- src/Makefile.am | 3 +-- src/Makefile.in | 3 +-- src/jpeg.c | 5 ++--- src/utils.c | 12 +++++++----- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index b99fdf1..68cb0a3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,3 @@ bin_PROGRAMS = caesiumclt caesiumclt_SOURCES = main.c jpeg.c compresshelper.c utils.c png.c lodepng.c -caesiumclt_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -std=c99 -caesiumclt_LDADD = -ljpeg -lturbojpeg -lm -lzopflipng \ No newline at end of file +caesiumclt_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -std=c99 \ No newline at end of file diff --git a/src/Makefile.in b/src/Makefile.in index f75e2cc..f94993c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -103,7 +103,7 @@ am_caesiumclt_OBJECTS = caesiumclt-main.$(OBJEXT) \ caesiumclt-utils.$(OBJEXT) caesiumclt-png.$(OBJEXT) \ caesiumclt-lodepng.$(OBJEXT) caesiumclt_OBJECTS = $(am_caesiumclt_OBJECTS) -caesiumclt_DEPENDENCIES = +caesiumclt_LDADD = $(LDADD) caesiumclt_LINK = $(CCLD) $(caesiumclt_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) @@ -255,7 +255,6 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ caesiumclt_SOURCES = main.c jpeg.c compresshelper.c utils.c png.c lodepng.c caesiumclt_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -std=c99 -caesiumclt_LDADD = -ljpeg -lturbojpeg -lm -lzopflipng all: all-am .SUFFIXES: diff --git a/src/jpeg.c b/src/jpeg.c index 516cfa1..13c5697 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -150,7 +150,6 @@ void cclt_jpeg_compress(char* output_file, unsigned char* image_buffer, cclt_com FILE* fp; tjhandle tjCompressHandle; unsigned char* output_buffer; - int status; unsigned long output_size = 0; fp = fopen(output_file, "wb"); @@ -166,7 +165,8 @@ void cclt_jpeg_compress(char* output_file, unsigned char* image_buffer, cclt_com tjCompressHandle = tjInitCompress(); //TODO Scale must be a power of 2. Can we resolve it? - status = tjCompress2(tjCompressHandle, + //TODO Error checks + tjCompress2(tjCompressHandle, image_buffer, pars->width, 0, @@ -178,7 +178,6 @@ void cclt_jpeg_compress(char* output_file, unsigned char* image_buffer, cclt_com pars->quality, pars->dct_method); - fwrite(output_buffer, 1, output_size, fp); fclose(fp); diff --git a/src/utils.c b/src/utils.c index 5450eeb..30e7501 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -102,9 +103,10 @@ char** scan_folder(char* basedir, int* n, int recur) { char** fileList = NULL; char absolute_path[PATH_MAX]; - realpath(basedir, absolute_path); + char* ptr = realpath(basedir, absolute_path); - dir = opendir(absolute_path); + + dir = opendir(ptr); if (dir != NULL) { while ((ent = readdir(dir)) != NULL) { @@ -115,8 +117,8 @@ char** scan_folder(char* basedir, int* n, int recur) { //TODO allocate for this entry //Basedir + filename + separator - entpath = realloc(entpath, (strlen(absolute_path) + strlen(ent->d_name) + 1) * sizeof(char)); - strcpy(entpath, absolute_path); + entpath = realloc(entpath, (strlen(ptr) + strlen(ent->d_name) + 1) * sizeof(char)); + strcpy(entpath, ptr); //Append separator strcat(entpath, "/"); //Append the name @@ -156,7 +158,7 @@ char** scan_folder(char* basedir, int* n, int recur) { enum image_type detect_image_type(char* path) { //Open the file FILE* fp; - unsigned char* type_buffer = valloc(2); + unsigned char* type_buffer = (unsigned char*) malloc(2); fp = fopen(path, "r");