Transferring loads of array variables from Stack to Heap

This commit is contained in:
Hombre
2010-12-27 12:47:45 +01:00
parent 69284246b1
commit 6152b5d9dd
26 changed files with 192 additions and 73 deletions

View File

@@ -621,7 +621,7 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality) {
jpeg_start_compress(&cinfo, TRUE);
// buffer for exif and iptc markers
unsigned char buffer[165535];
unsigned char* buffer = new unsigned char[165535]; //TODO: Is it really 165535... or 65535 ?
unsigned int size;
// assemble and write exif marker
if (exifRoot) {
@@ -674,6 +674,8 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality) {
jpeg_destroy_compress (&cinfo);
delete [] row;
delete [] buffer;
fclose (file);
if (pl) {
@@ -707,7 +709,7 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) {
}
// buffer for the exif and iptc
unsigned char buffer[165535];
unsigned char* buffer = new unsigned char[165535]; //TODO: Is it really 165535... or 65535 ?
unsigned char* iptcdata = NULL;
unsigned int iptclen = 0;
if (iptc && iptc_data_save (iptc, &iptcdata, &iptclen) && iptcdata) {
@@ -717,6 +719,9 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) {
int size = rtexif::ExifManager::createTIFFHeader (exifRoot, exifChange, width, height, bps, profileData, profileLength, (char*)iptcdata, iptclen, buffer);
if (iptcdata)
iptc_data_free_buf (iptc, iptcdata);
// The maximum lenght is strangely not the same than for the JPEG file...
// Which maximum length is the good one ?
if (size>0 && size<165530)
fwrite (buffer, size, 1, file);
@@ -734,6 +739,7 @@ int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) {
if (pl && !(i%100))
pl->setProgress ((double)(i+1)/height);
}
delete [] buffer;
fclose (file);
}