summaryrefslogtreecommitdiff
path: root/dmagick/Array.d
diff options
context:
space:
mode:
authorMike Wey2012-04-09 14:35:41 +0200
committerMike Wey2012-04-09 14:35:41 +0200
commit811e5806d29c0856b182c278ec544a7fe4be4175 (patch)
tree051e33ec2af526c070b982f01cd59b5ba2ae6931 /dmagick/Array.d
parent90958a9bc18b13cb76581eea7ab7d99b8d831601 (diff)
Don't try to use the D GC when creating blobs.
This causes segfaults, see issue #4.
Diffstat (limited to 'dmagick/Array.d')
-rw-r--r--dmagick/Array.d14
1 files changed, 4 insertions, 10 deletions
diff --git a/dmagick/Array.d b/dmagick/Array.d
index 339de5c..7778af7 100644
--- a/dmagick/Array.d
+++ b/dmagick/Array.d
@@ -595,26 +595,20 @@ void[] toBlob(Image[] images, string magick = null, size_t depth = 0, bool adjoi
{
size_t length;
- AcquireMemoryHandler oldMalloc;
- ResizeMemoryHandler oldRealloc;
- DestroyMemoryHandler oldFree;
-
if ( magick !is null )
images[0].magick = magick;
if ( depth != 0 )
images[0].depth = depth;
- //Use the D GC to accolate the blob.
- GetMagickMemoryMethods(&oldMalloc, &oldRealloc, &oldFree);
- SetMagickMemoryMethods(&Image.malloc, &Image.realloc, &Image.free);
- scope(exit) SetMagickMemoryMethods(oldMalloc, oldRealloc, oldFree);
-
linkImages(images);
scope(exit) unlinkImages(images);
void* blob = ImagesToBlob(images[0].options.imageInfo, images[0].imageRef, &length, DMagickExceptionInfo());
- return blob[0 .. length];
+ void[] dBlob = blob[0 .. length].dup;
+ RelinquishMagickMemory(blob);
+
+ return dBlob;
}
/**