lib/localmem.c File Reference

#include "common.h"
#include "localmem.h"

Include dependency graph for localmem.c:

Go to the source code of this file.

Data Structures

struct  lm
struct  lmBlock

Functions

static struct lmBlocknewBlock (struct lm *lm, size_t reqSize)
lmlmInit (int blockSize)
void lmCleanup (struct lm **pLm)
void * lmAlloc (struct lm *lm, size_t size)
void * lmCloneMem (struct lm *lm, void *pt, size_t size)
char * lmCloneString (struct lm *lm, char *string)
slNamelmSlName (struct lm *lm, char *name)

Variables

static char const rcsid [] = "$Id: localmem.c,v 1.10 2005/04/11 07:20:03 markd Exp $"


Function Documentation

void* lmAlloc ( struct lm lm,
size_t  size 
)

Definition at line 78 of file localmem.c.

References lm::allignAdd, lm::allignMask, lm::blocks, lmBlock::end, lmBlock::free, lm, and newBlock().

Referenced by ffNeedMem(), gffNeedMem(), hashAddN(), lmCloneMem(), lmCloneString(), lmSlName(), localNeedMem(), newFofRecEl(), newHash(), pslLoadLm(), pslxLoadLm(), and rbTreeNew().

00080 {
00081 struct lmBlock *mb = lm->blocks;
00082 void *ret;
00083 size_t memLeft = mb->end - mb->free;
00084 if (memLeft < size)
00085     mb = newBlock(lm, size);
00086 ret = mb->free;
00087 mb->free += ((size+lm->allignAdd)&lm->allignMask);
00088 if (mb->free > mb->end)
00089     mb->free = mb->end;
00090 return ret;
00091 }

Here is the call graph for this function:

Here is the caller graph for this function:

void lmCleanup ( struct lm **  pLm  ) 

Definition at line 67 of file localmem.c.

References lm::blocks, freeMem(), lm, and slFreeList().

Referenced by bandExt(), chainBlocks(), cleanupMem(), dnaQuery(), ffMemCleanup(), fofMake(), freeHash(), genoFindDirect(), gfAlignTrans(), gfAlignTransTrans(), gffClose(), gfFindAlignAaTrans(), gfTransTransFindBundles(), rbTreeFree(), searchOneProt(), ssFindBestBig(), transQuery(), and transTransQuery().

00069 {
00070     struct lm *lm = *pLm;
00071     if (lm == NULL)
00072         return;
00073     slFreeList(&lm->blocks);
00074     freeMem(lm);
00075     *pLm = NULL;
00076 }

Here is the call graph for this function:

Here is the caller graph for this function:

void* lmCloneMem ( struct lm lm,
void *  pt,
size_t  size 
)

Definition at line 93 of file localmem.c.

References lm, and lmAlloc().

Referenced by rangeTreeAdd().

00095 {
00096 void *d = lmAlloc(lm, size);
00097 memcpy(d, pt, size);
00098 return d;
00099 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* lmCloneString ( struct lm lm,
char *  string 
)

Definition at line 101 of file localmem.c.

References lm, and lmAlloc().

Referenced by hashTwoColumnFile(), pslLoadLm(), pslxLoadLm(), raFoldInOneRetName(), raFromString(), and raNextRecord().

00103 {
00104 if (string == NULL)
00105     return NULL;
00106 else
00107     {
00108     int size = strlen(string)+1;
00109     char *s = lmAlloc(lm, size);
00110     memcpy(s, string, size);
00111     return s;
00112     }
00113 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct lm* lmInit ( int  blockSize  )  [read]

Definition at line 47 of file localmem.c.

References lm, needMem(), and newBlock().

Referenced by bandExt(), boxFindClumps(), chainBlocks(), dnaQuery(), ffFindExtendNmers(), ffMemInit(), fofMake(), genoFindDirect(), gfAlignTrans(), gfAlignTransTrans(), gfFindAlignAaTrans(), gffOpen(), gfLongDnaInMem(), gfTransTransFindBundles(), initMem(), newHash(), rbTreeNew(), searchOneProt(), ssFindBestBig(), transQuery(), and transTransQuery().

00049 {
00050 struct lm *lm;
00051 int aliSize = sizeof(long);
00052 if (aliSize < sizeof(double))
00053     aliSize = sizeof(double);
00054 if (aliSize < sizeof(void *))
00055     aliSize = sizeof(void *);
00056 lm = needMem(sizeof(*lm));
00057 lm->blocks = NULL;
00058 if (blockSize <= 0)
00059     blockSize = (1<<14);    /* 16k default. */
00060 lm->blockSize = blockSize;
00061 lm->allignAdd = (aliSize-1);
00062 lm->allignMask = ~lm->allignAdd;
00063 newBlock(lm, blockSize);
00064 return lm;
00065 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct slName* lmSlName ( struct lm lm,
char *  name 
) [read]

Definition at line 115 of file localmem.c.

References lm, lmAlloc(), and slName::name.

00117 {
00118 struct slName *n;
00119 int size = sizeof(*n) + strlen(name) + 1;
00120 n = lmAlloc(lm, size);
00121 strcpy(n->name, name);
00122 return n;
00123 }

Here is the call graph for this function:

static struct lmBlock* newBlock ( struct lm lm,
size_t  reqSize 
) [static, read]

Definition at line 32 of file localmem.c.

References lm::blocks, lm::blockSize, lmBlock::end, errAbort(), lmBlock::free, lm, needLargeZeroedMem(), and lmBlock::next.

Referenced by lmAlloc(), and lmInit().

00034 {
00035 size_t size = (reqSize > lm->blockSize ? reqSize : lm->blockSize);
00036 size_t fullSize = size + sizeof(struct lmBlock);
00037 struct lmBlock *mb = needLargeZeroedMem(fullSize);
00038 if (mb == NULL)
00039     errAbort("Couldn't allocate %lld bytes", (long long)fullSize);
00040 mb->free = (char *)(mb+1);
00041 mb->end = ((char *)mb) + fullSize;
00042 mb->next = lm->blocks;
00043 lm->blocks = mb;
00044 return mb;
00045 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char const rcsid[] = "$Id: localmem.c,v 1.10 2005/04/11 07:20:03 markd Exp $" [static]

Definition at line 14 of file localmem.c.


Generated on Tue Dec 25 19:59:03 2007 for blat by  doxygen 1.5.2