mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Use FreeCallback to support mixed Windows runtime libs #152
This commit is contained in:
9
src/common.cc
Executable file → Normal file
9
src/common.cc
Executable file → Normal file
@@ -177,4 +177,13 @@ namespace sharp {
|
||||
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
|
||||
|
||||
5
src/common.h
Executable file → Normal file
5
src/common.h
Executable file → Normal file
@@ -80,6 +80,11 @@ namespace sharp {
|
||||
*/
|
||||
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
|
||||
|
||||
#endif // SRC_COMMON_H_
|
||||
|
||||
11
src/metadata.cc
Executable file → Normal file
11
src/metadata.cc
Executable file → Normal file
@@ -35,6 +35,7 @@ using sharp::InitImage;
|
||||
using sharp::HasProfile;
|
||||
using sharp::HasAlpha;
|
||||
using sharp::ExifOrientation;
|
||||
using sharp::FreeCallback;
|
||||
using sharp::counterQueue;
|
||||
|
||||
struct MetadataBaton {
|
||||
@@ -175,10 +176,16 @@ class MetadataWorker : public AsyncWorker {
|
||||
Set(info, New("orientation").ToLocalChecked(), New<Number>(baton->orientation));
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
5
src/pipeline.cc
Executable file → Normal file
5
src/pipeline.cc
Executable file → Normal file
@@ -55,6 +55,7 @@ using sharp::IsPng;
|
||||
using sharp::IsWebp;
|
||||
using sharp::IsTiff;
|
||||
using sharp::IsDz;
|
||||
using sharp::FreeCallback;
|
||||
using sharp::counterProcess;
|
||||
using sharp::counterQueue;
|
||||
|
||||
@@ -959,7 +960,9 @@ class PipelineWorker : public AsyncWorker {
|
||||
|
||||
if (baton->bufferOutLength > 0) {
|
||||
// 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
|
||||
Set(info, New("size").ToLocalChecked(), New<Uint32>(static_cast<uint32_t>(baton->bufferOutLength)));
|
||||
argv[2] = info;
|
||||
|
||||
Reference in New Issue
Block a user