]> granicus.if.org Git - imagemagick/blob - Magick++/lib/BlobRef.cpp
EnableOpenCL returns true if OpenCL was enabled successfully.
[imagemagick] / Magick++ / lib / BlobRef.cpp
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2004
4 //
5 // Implementation of Blob
6 //
7
8 #define MAGICKCORE_IMPLEMENTATION  1
9 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
10
11 #include "Magick++/Include.h"
12 #include "Magick++/Thread.h"
13 #include "Magick++/BlobRef.h"
14
15 #include <string.h>
16
17 Magick::BlobRef::BlobRef(const void* data_,size_t length_)
18   : data(0),
19     length(length_),
20     allocator(Magick::Blob::NewAllocator),
21     refCount(1),
22     mutexLock()
23 {
24   if (data_)
25     {
26       data=new unsigned char[length_];
27       memcpy(data,data_, length_);
28     }
29 }
30
31 Magick::BlobRef::~BlobRef(void)
32 {
33   if (allocator == Magick::Blob::NewAllocator)
34     {
35       delete[] static_cast<unsigned char*>(data);
36       data=0;
37     }
38   else if (allocator == Magick::Blob::MallocAllocator)
39     {
40       data=(void *) RelinquishMagickMemory(data);
41     }
42 }