diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-07-05 21:52:55 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-07-05 21:52:55 +0200 |
commit | 29ecf5a14953471a061e5022563a6edd09d9dbef (patch) | |
tree | 7b03df7c40b4fd8f8050b770e9edea5d48b4eba2 /src/JPEGOutputImage.cxx | |
parent | db527409f2c6f21195245484e936573a3c76f028 (diff) |
OutputImage cleanup
Diffstat (limited to 'src/JPEGOutputImage.cxx')
-rw-r--r-- | src/JPEGOutputImage.cxx | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/JPEGOutputImage.cxx b/src/JPEGOutputImage.cxx index 0f3cf18..263eeb3 100644 --- a/src/JPEGOutputImage.cxx +++ b/src/JPEGOutputImage.cxx @@ -21,31 +21,26 @@ JPEGOutputImage::JPEGOutputImage(const char *f, int q) { } JPEGOutputImage::~JPEGOutputImage() { - if (row) { + if (row) free(row); - } - if (file) { + if (file) free(file); - } } int -JPEGOutputImage::init_internal(int w1, int h1) { - if (row) { +JPEGOutputImage::init_internal() { + if (row) free(row); - row = NULL; - } + row = NULL; - row = (unsigned char*) malloc(sizeof(char) * 3 * W); + row = (unsigned char*) calloc(3 * W, sizeof(char)); if (!row) { - perror("malloc"); + perror("calloc"); return 1; } - memset(row, 0, sizeof(char) * 3 * W); - if (fp) { + if (fp) fclose(fp); - } if ((fp = fopen(file, "wb")) == NULL) { fprintf(stderr, "can't open %s\n", file); @@ -92,18 +87,18 @@ JPEGOutputImage::done_internal() { jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); - if (fp) { + if (fp) fclose(fp); - fp = NULL; - } - if (row) { + fp = NULL; + + if (row) free(row); - } + row = NULL; - if (fp) { + if (fp) fclose(fp); - fp = NULL; - } + fp = NULL; + return 0; } |