Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__jpeg_decoder__Proj
comparison VSs_tinyjpeg/loadjpeg.c @ 2:a52de05d2e2b
changed malloc to VMS malloc
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 10 Jul 2012 11:42:46 +0200 |
| parents | 7e13c9ecc89c |
| children | 42d636fee562 |
comparison
equal
deleted
inserted
replaced
| 1:59abd2f874ea | 2:661acb10b069 |
|---|---|
| 128 /* Load the Jpeg into memory */ | 128 /* Load the Jpeg into memory */ |
| 129 fp = fopen(infilename, "rb"); | 129 fp = fopen(infilename, "rb"); |
| 130 if (fp == NULL) | 130 if (fp == NULL) |
| 131 perror("Cannot open image");//exitmessage("Cannot open filename\n"); | 131 perror("Cannot open image");//exitmessage("Cannot open filename\n"); |
| 132 length_of_file = filesize(fp); | 132 length_of_file = filesize(fp); |
| 133 buf = (unsigned char *)malloc(length_of_file + 4); | 133 buf = (unsigned char *)VMS_App__malloc(length_of_file + 4); |
| 134 if (buf == NULL) | 134 if (buf == NULL) |
| 135 exitmessage("Not enough memory for loading file\n"); | 135 exitmessage("Not enough memory for loading file\n"); |
| 136 fread(buf, length_of_file, 1, fp); | 136 fread(buf, length_of_file, 1, fp); |
| 137 fclose(fp); | 137 fclose(fp); |
| 138 | 138 |
| 146 | 146 |
| 147 /* Get the size of the image */ | 147 /* Get the size of the image */ |
| 148 tinyjpeg_get_size(jdec, &width, &height); | 148 tinyjpeg_get_size(jdec, &width, &height); |
| 149 | 149 |
| 150 // RGB stuff | 150 // RGB stuff |
| 151 rgb_data = (uint8_t *)malloc(width * height * RGB_DEPTH); | 151 rgb_data = (uint8_t *)VMS_App__malloc(width * height * RGB_DEPTH); |
| 152 jdec->components[0] = rgb_data; | 152 jdec->components[0] = rgb_data; |
| 153 | 153 |
| 154 // this jpeg decoder only supports full MCUs for simplicity | 154 // this jpeg decoder only supports full MCUs for simplicity |
| 155 ntasks = (jdec->mcus_in_width * jdec->mcus_in_height)/ jdec->restart_interval; | 155 ntasks = (jdec->mcus_in_width * jdec->mcus_in_height)/ jdec->restart_interval; |
| 156 jdec_task = (struct jdec_private **) malloc ( ntasks * sizeof(struct jdec_private*)); | 156 jdec_task = (struct jdec_private **) VMS_App__malloc ( ntasks * sizeof(struct jdec_private*)); |
| 157 | 157 |
| 158 | 158 |
| 159 //VSs setup | 159 //VSs setup |
| 160 tinyjpegTaskType = VMS_App__malloc( sizeof(VSsTaskType) ); | 160 tinyjpegTaskType = VMS_App__malloc( sizeof(VSsTaskType) ); |
| 161 tinyjpegTaskType->fn = &tinyjpeg_decode_task; | 161 tinyjpegTaskType->fn = &tinyjpeg_decode_task; |
| 189 tinyjpeg_free(jdec); | 189 tinyjpeg_free(jdec); |
| 190 for(i=0; i < ntasks; i++) { | 190 for(i=0; i < ntasks; i++) { |
| 191 tinyjpeg_free(jdec_task[i]); | 191 tinyjpeg_free(jdec_task[i]); |
| 192 } | 192 } |
| 193 fclose(fp); | 193 fclose(fp); |
| 194 free(buf); | 194 VMS_App__free(buf); |
| 195 free(rgb_data); | 195 VMS_App__free(rgb_data); |
| 196 free(jdec_task); | 196 VMS_App__free(jdec_task); |
| 197 return 0; | 197 return 0; |
| 198 } | 198 } |
| 199 | 199 |
| 200 /* | 200 /* |
| 201 * Usage information. | 201 * Usage information. |
