Use FreeCallback to support mixed Windows runtime libs #152

This commit is contained in:
Lovell Fuller 2015-11-14 13:58:05 +00:00
parent ede2ee9ce3
commit 2678d761ba
6 changed files with 37 additions and 6 deletions

View File

@ -54,9 +54,9 @@ var error = function(msg) {
module.exports.download_vips = function() { module.exports.download_vips = function() {
// Has vips been installed locally? // Has vips been installed locally?
if (!isFile(vipsHeaderPath)) { if (!isFile(vipsHeaderPath)) {
// 32-bit // Ensure 64-bit
if (process.arch === 'ia32') { if (process.arch !== 'x64') {
error('32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/'); error('ARM and 32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/');
} }
// Ensure libc >= 2.15 // Ensure libc >= 2.15
var lddVersion = process.env.LDD_VERSION; var lddVersion = process.env.LDD_VERSION;

9
src/common.cc Executable file → Normal file
View File

@ -177,4 +177,13 @@ namespace sharp {
return window_size; return window_size;
} }
/*
Called when a Buffer undergoes GC, required to support mixed runtime libraries in Windows
*/
void FreeCallback(char* data, void* hint) {
if (data != NULL) {
g_free(data);
}
}
} // namespace sharp } // namespace sharp

5
src/common.h Executable file → Normal file
View File

@ -80,6 +80,11 @@ namespace sharp {
*/ */
int InterpolatorWindowSize(char const *name); int InterpolatorWindowSize(char const *name);
/*
Called when a Buffer undergoes GC, required to support mixed runtime libraries in Windows
*/
void FreeCallback(char* data, void* hint);
} // namespace sharp } // namespace sharp
#endif // SRC_COMMON_H_ #endif // SRC_COMMON_H_

11
src/metadata.cc Executable file → Normal file
View File

@ -35,6 +35,7 @@ using sharp::InitImage;
using sharp::HasProfile; using sharp::HasProfile;
using sharp::HasAlpha; using sharp::HasAlpha;
using sharp::ExifOrientation; using sharp::ExifOrientation;
using sharp::FreeCallback;
using sharp::counterQueue; using sharp::counterQueue;
struct MetadataBaton { struct MetadataBaton {
@ -175,10 +176,16 @@ class MetadataWorker : public AsyncWorker {
Set(info, New("orientation").ToLocalChecked(), New<Number>(baton->orientation)); Set(info, New("orientation").ToLocalChecked(), New<Number>(baton->orientation));
} }
if (baton->exifLength > 0) { if (baton->exifLength > 0) {
Set(info, New("exif").ToLocalChecked(), NewBuffer(baton->exif, baton->exifLength).ToLocalChecked()); Set(info,
New("exif").ToLocalChecked(),
NewBuffer(baton->exif, baton->exifLength, FreeCallback, nullptr).ToLocalChecked()
);
} }
if (baton->iccLength > 0) { if (baton->iccLength > 0) {
Set(info, New("icc").ToLocalChecked(), NewBuffer(baton->icc, baton->iccLength).ToLocalChecked()); Set(info,
New("icc").ToLocalChecked(),
NewBuffer(baton->icc, baton->iccLength, FreeCallback, nullptr).ToLocalChecked()
);
} }
argv[1] = info; argv[1] = info;
} }

5
src/pipeline.cc Executable file → Normal file
View File

@ -55,6 +55,7 @@ using sharp::IsPng;
using sharp::IsWebp; using sharp::IsWebp;
using sharp::IsTiff; using sharp::IsTiff;
using sharp::IsDz; using sharp::IsDz;
using sharp::FreeCallback;
using sharp::counterProcess; using sharp::counterProcess;
using sharp::counterQueue; using sharp::counterQueue;
@ -959,7 +960,9 @@ class PipelineWorker : public AsyncWorker {
if (baton->bufferOutLength > 0) { if (baton->bufferOutLength > 0) {
// Pass ownership of output data to Buffer instance // Pass ownership of output data to Buffer instance
argv[1] = NewBuffer(static_cast<char*>(baton->bufferOut), baton->bufferOutLength).ToLocalChecked(); argv[1] = NewBuffer(
static_cast<char*>(baton->bufferOut), baton->bufferOutLength, FreeCallback, nullptr
).ToLocalChecked();
// Add buffer size to info // Add buffer size to info
Set(info, New("size").ToLocalChecked(), New<Uint32>(static_cast<uint32_t>(baton->bufferOutLength))); Set(info, New("size").ToLocalChecked(), New<Uint32>(static_cast<uint32_t>(baton->bufferOutLength)));
argv[2] = info; argv[2] = info;

View File

@ -285,6 +285,13 @@
... ...
fun:get_bands fun:get_bands
} }
{
value_magick_is_palette_image
Memcheck:Value8
fun:IsPaletteImage
...
fun:get_bands
}
# glib g_file_read_link # glib g_file_read_link
# https://github.com/GNOME/glib/commit/49a5d0f6f2aed99cd78f25655f137f4448e47d92 # https://github.com/GNOME/glib/commit/49a5d0f6f2aed99cd78f25655f137f4448e47d92