Debug prints now only in debug builds

This commit is contained in:
Phuntsok Drak-pa 2018-11-23 10:31:47 +01:00
parent 9c843e6af3
commit 87dfa5b2a6
No known key found for this signature in database
GPG Key ID: 9CB34B6827C66D22
4 changed files with 21 additions and 14 deletions

View File

@ -106,24 +106,25 @@ darray* imgToZones(Image* t_img) {
}
void compress(const char *input_file) {
Image* img;
Image *img;
darray *zones;
img = newImage();
imageLoadPPM(input_file, img);
zones = imgToZones(img);
printf("Detected %zu zones\n", darraySize(zones));
for(size_t i = 0; i < darraySize(zones); ++i) {
Zone* zone = darrayGet(zones, i);
printf("\n=== Zone %zu (%d %d %d) ===\n", i, zone->r, zone->g, zone->b);
for(size_t j = 0; j < darraySize(zone->segments); ++j) {
Segment* segm = darrayGet(zone->segments, j);
printf("[%d: %d, %d]\t", segm->y, segm->xg, segm->xd);
/* print segments for debug ************************************************/
DEBUG {
printf("Detected %zu zones\n", darraySize(zones));
for (size_t i = 0; i < darraySize(zones); ++i) {
Zone *zone = darrayGet(zones, i);
printf("\n=== Zone %zu (%d %d %d) ===\n", i, zone->r, zone->g, zone->b);
for (size_t j = 0; j < darraySize(zone->segments); ++j) {
Segment *segm = darrayGet(zone->segments, j);
printf("[%zu: %d, %d]\t", segm->xg / img->x, segm->xg, segm->xd);
}
}
printf("\n");
}
printf("\n");
deleteImage(img);
printf("test\n");
}

View File

@ -122,7 +122,9 @@ int main(int argc, char **argv) {
fprintf(stderr, "ERROR: no input file.");
help(ARGERROR);
}
printf("input: %s\noutput: %s\n", argresults.input, argresults.output);
DEBUG {
printf("input: %s\noutput: %s\n", argresults.input, argresults.output);
}
if(argresults.compress) {
compress(argresults.input);
} else {

View File

@ -111,7 +111,9 @@ unsigned long read_data(FILE *t_fp, Image *t_img, unsigned char **t_data,
unsigned long size;
/* allocation memoire */
size = t_img->x * t_img->y * 3;
printf("Size image %lu %lu => %lu\n", t_img->x, t_img->y, size);
DEBUG {
printf("Size image %lu %lu => %lu\n", t_img->x, t_img->y, t_img->x * t_img->y);
}
*t_data = (unsigned char *)malloc((size_t)size * sizeof(unsigned char));
assert(*t_data);
/* read pixel data from file */

View File

@ -63,7 +63,9 @@ Image *newImage() {
* \param[in] self Conteneur dimage à détruire
*/
void deleteImage(Image *t_self) {
printf("deleted all pixels\n");
DEBUG {
printf("deleted all pixels\n");
}
darrayDelete(t_self->pixels);
free(t_self);
}