Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Public Attributes
nsZlibAllocator Class Reference

#include <nsZlibAllocator.h>

Collaboration diagram for nsZlibAllocator:
Collaboration graph
[legend]

List of all members.

Classes

struct  nsMemBucket

Public Member Functions

 nsZlibAllocator ()
 ~nsZlibAllocator ()
voidzAlloc (PRUint32 items, PRUint32 size)
void zFree (void *ptr)
PRBool Claim (PRUint32 i)
void Unclaim (PRUint32 i)

Public Attributes

nsMemBucket mMemBucket [NBUCKETS]

Detailed Description

Definition at line 49 of file nsZlibAllocator.h.


Class Documentation

struct nsZlibAllocator::nsMemBucket

Definition at line 51 of file nsZlibAllocator.h.

Class Members
PRInt32 available
void * ptr
PRUint32 size

Constructor & Destructor Documentation

Definition at line 64 of file nsZlibAllocator.h.

                    {
    memset(mMemBucket, 0, sizeof(mMemBucket));
    for (PRUint32 i = 0; i < NBUCKETS; i++)
      mMemBucket[i].available = 1;
    return;
  }

Here is the call graph for this function:

Definition at line 71 of file nsZlibAllocator.h.

                     {
    for (PRUint32 i = 0; i < NBUCKETS; i++)
    {
      PRBool claimed = Claim(i);
      
      // ASSERT that we claimed the bucked. If we cannot, then the bucket is in use.
      // We dont attempt to free this ptr.
      // This will most likely cause a leak of this memory.
      PR_ASSERT(claimed);
      
      // Free bucket memory if not in use
      if (claimed && mMemBucket[i].ptr)
        free(mMemBucket[i].ptr);
    }
  }

Here is the call graph for this function:


Member Function Documentation

Definition at line 92 of file nsZlibAllocator.h.

                           {
    PRBool claimed = (PR_AtomicDecrement(&mMemBucket[i].available) == 0);
    // Undo the claim, if claim failed
    if (!claimed)
      Unclaim(i);

    return claimed;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file nsZlibAllocator.h.

{ PR_AtomicIncrement(&mMemBucket[i].available); }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 62 of file nsZlibAllocator.h.


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