1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2004
4 // Copyright Dirk Lemstra 2014-2015
6 // Implementation of Blob
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12 #include "Magick++/Include.h"
13 #include "Magick++/BlobRef.h"
14 #include "Magick++/Exception.h"
15 #include "Magick++/Thread.h"
19 Magick::BlobRef::BlobRef(const void* data_,const size_t length_)
20 : allocator(Magick::Blob::NewAllocator),
26 if (data_ != (const void*) NULL)
28 data=new unsigned char[length_];
29 memcpy(data,data_,length_);
33 Magick::BlobRef::~BlobRef(void)
35 if (allocator == Magick::Blob::NewAllocator)
37 delete[] static_cast<unsigned char*>(data);
40 else if (allocator == Magick::Blob::MallocAllocator)
41 data=(void *) RelinquishMagickMemory(data);
44 size_t Magick::BlobRef::decrease()
53 throwExceptionExplicit(MagickCore::OptionError,
54 "Invalid call to decrease");
62 void Magick::BlobRef::increase()