Magick++ 7.1.1
Loading...
Searching...
No Matches
Magick::BlobRef Class Reference
Collaboration diagram for Magick::BlobRef:

Public Member Functions

 BlobRef (const void *data_, const size_t length_)
 
size_t decrease ()
 
void increase ()
 

Public Attributes

Blob::Allocator allocator
 
size_t length
 
void * data
 

Private Member Functions

 BlobRef (const BlobRef &)
 
BlobRefoperator= (const BlobRef &)
 

Private Attributes

MutexLock _mutexLock
 
size_t _refCount
 

Detailed Description

Definition at line 23 of file BlobRef.h.

Constructor & Destructor Documentation

◆ BlobRef()

Magick::BlobRef::BlobRef ( const void *  data_,
const size_t  length_ 
)

Definition at line 21 of file BlobRef.cpp.

22 : allocator(Magick::Blob::NewAllocator),
23 length(length_),
24 data((void*) NULL),
25 _mutexLock(),
26 _refCount(1)
27{
28 if (data_ != (const void*) NULL)
29 {
30 data=new unsigned char[length_];
31 memcpy(data,data_,length_);
32 }
33}

◆ ~BlobRef()

Magick::BlobRef::~BlobRef ( void  )

Definition at line 35 of file BlobRef.cpp.

36{
37 if (allocator == Magick::Blob::NewAllocator)
38 {
39 delete[] static_cast<unsigned char*>(data);
40 data=(void *) NULL;
41 }
42 else if (allocator == Magick::Blob::MallocAllocator)
43 data=(void *) RelinquishMagickMemory(data);
44}

Member Function Documentation

◆ decrease()

size_t Magick::BlobRef::decrease ( )

Definition at line 46 of file BlobRef.cpp.

47{
48 size_t
49 count;
50
51 _mutexLock.lock();
52 if (_refCount == 0)
53 {
54 _mutexLock.unlock();
55 throwExceptionExplicit(MagickCore::OptionError,
56 "Invalid call to decrease");
57 return(0);
58 }
59 count=--_refCount;
60 _mutexLock.unlock();
61 return(count);
62}

◆ increase()

void Magick::BlobRef::increase ( )

Definition at line 64 of file BlobRef.cpp.

65{
66 _mutexLock.lock();
67 _refCount++;
68 _mutexLock.unlock();
69}

Member Data Documentation

◆ _mutexLock

MutexLock Magick::BlobRef::_mutexLock
private

Definition at line 48 of file BlobRef.h.

◆ _refCount

size_t Magick::BlobRef::_refCount
private

Definition at line 49 of file BlobRef.h.

◆ allocator

Blob::Allocator Magick::BlobRef::allocator

Definition at line 39 of file BlobRef.h.

◆ data

void* Magick::BlobRef::data

Definition at line 41 of file BlobRef.h.

◆ length

size_t Magick::BlobRef::length

Definition at line 40 of file BlobRef.h.


The documentation for this class was generated from the following files: