Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
RgnRectMemoryAllocator Class Reference

List of all members.

Public Member Functions

 RgnRectMemoryAllocator (PRUint32 aNumOfEntries)
 ~RgnRectMemoryAllocator ()
nsRegion::RgnRect * Alloc ()
void Free (nsRegion::RgnRect *aRect)

Private Member Functions

void InitLock ()
void DestroyLock ()
void Lock ()
void Unlock ()
voidAllocChunk (PRUint32 aEntries, void *aNextChunk, nsRegion::RgnRect *aTailDest)
void FreeChunk (void *aChunk)
voidNextChunk (void *aThisChunk) const
nsRegion::RgnRect * ChunkHead (void *aThisChunk) const

Private Attributes

nsRegion::RgnRect * mFreeListHead
PRUint32 mFreeEntries
voidmChunkListHead

Detailed Description

Definition at line 95 of file nsRegion.cpp.


Constructor & Destructor Documentation

Definition at line 150 of file nsRegion.cpp.

Here is the call graph for this function:

Definition at line 158 of file nsRegion.cpp.

{
  while (mChunkListHead)
  {
    void* tmp = mChunkListHead;
    mChunkListHead = NextChunk (mChunkListHead);
    FreeChunk (tmp);
  }

#if 0
  /*
   * As a static object this class outlives any library which would implement
   * locking. So we intentionally leak the 'lock'.
   *
   * Currently RgnRectMemoryAllocator is only used from the primary thread,
   * so we aren't using a lock which means that there is no lock to leak.
   * If we ever switch to multiple GUI threads (e.g. one per window),
   * we'd probably use one allocator per window-thread to avoid the
   * locking overhead and just require consumers not to pass regions
   * across threads/windows, which would be a reasonable restriction
   * because they wouldn't be useful outside their window.
   */
  DestroyLock ();
#endif
}

Here is the call graph for this function:


Member Function Documentation

nsRegion::RgnRect * RgnRectMemoryAllocator::Alloc ( )

Definition at line 184 of file nsRegion.cpp.

Here is the call graph for this function:

void* RgnRectMemoryAllocator::AllocChunk ( PRUint32  aEntries,
void aNextChunk,
nsRegion::RgnRect *  aTailDest 
) [inline, private]

Definition at line 121 of file nsRegion.cpp.

  {
    PRUint8* pBuf = new PRUint8 [aEntries * sizeof (nsRegion::RgnRect) + sizeof (void*)];
    *NS_REINTERPRET_CAST (void**, pBuf) = aNextChunk;
    nsRegion::RgnRect* pRect = NS_REINTERPRET_CAST (nsRegion::RgnRect*, pBuf + sizeof (void*));

    for (PRUint32 cnt = 0 ; cnt < aEntries - 1 ; cnt++)
      pRect [cnt].next = &pRect [cnt + 1];

    pRect [aEntries - 1].next = aTailDest;

    return pBuf;
  }

Here is the caller graph for this function:

nsRegion::RgnRect* RgnRectMemoryAllocator::ChunkHead ( void aThisChunk) const [inline, private]

Definition at line 138 of file nsRegion.cpp.

  {   return NS_REINTERPRET_CAST (nsRegion::RgnRect*, NS_STATIC_CAST (PRUint8*, aThisChunk) + sizeof (void*));  }

Here is the caller graph for this function:

Definition at line 116 of file nsRegion.cpp.

{ }

Here is the caller graph for this function:

void RgnRectMemoryAllocator::Free ( nsRegion::RgnRect *  aRect)

Definition at line 203 of file nsRegion.cpp.

{
  Lock ();
  mFreeEntries++;
  aRect->next = mFreeListHead;
  mFreeListHead = aRect;
  Unlock ();
}

Here is the call graph for this function:

void RgnRectMemoryAllocator::FreeChunk ( void aChunk) [inline, private]

Definition at line 135 of file nsRegion.cpp.

{  delete [] (PRUint8 *) aChunk;  }

Here is the caller graph for this function:

void RgnRectMemoryAllocator::InitLock ( ) [inline, private]

Definition at line 115 of file nsRegion.cpp.

{ }

Here is the caller graph for this function:

void RgnRectMemoryAllocator::Lock ( void  ) [inline, private]

Definition at line 117 of file nsRegion.cpp.

{ }

Here is the caller graph for this function:

void* RgnRectMemoryAllocator::NextChunk ( void aThisChunk) const [inline, private]

Definition at line 136 of file nsRegion.cpp.

{ return *NS_STATIC_CAST (void**, aThisChunk); }

Here is the caller graph for this function:

void RgnRectMemoryAllocator::Unlock ( void  ) [inline, private]

Definition at line 118 of file nsRegion.cpp.

{ }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 99 of file nsRegion.cpp.

Definition at line 98 of file nsRegion.cpp.

nsRegion::RgnRect* RgnRectMemoryAllocator::mFreeListHead [private]

Definition at line 97 of file nsRegion.cpp.


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