Memory.cpp File Reference

Go to the source code of this file.

Classes

class  UnreferencedCommonStructs

Functions

void * operator new[] (unsigned sz) throw (std::bad_alloc)
void operator delete[] (void *p) throw ()
 FENNEL_BEGIN_CPPFILE ("$Id: //open/dev/fennel/common/Memory.cpp#12 $")
std::logic_error constructAssertion (char const *pFilename, int lineNum, char const *condExpr)
int getCurrentThreadId ()
void hexDump (std::ostream &o, void const *v, uint cb, uint cbDone)
 FENNEL_END_CPPFILE ("$Id: //open/dev/fennel/common/Memory.cpp#12 $")


Function Documentation

std::logic_error constructAssertion ( char const *  pFilename,
int  lineNum,
char const *  condExpr 
)

Definition at line 64 of file Memory.cpp.

00066 {
00067     boost::format fmt("Assertion `%1%' failed at line %2% in file %3%");
00068     return std::logic_error(
00069         (fmt % condExpr % lineNum % pFilename).str());
00070 }

FENNEL_BEGIN_CPPFILE ( "$Id: //open/dev/fennel/common/Memory.cpp#12 $"   ) 

FENNEL_END_CPPFILE ( "$Id: //open/dev/fennel/common/Memory.cpp#12 $"   ) 

int getCurrentThreadId (  ) 

Definition at line 72 of file Memory.cpp.

Referenced by LockHolderId::assignFrom(), and get_tid().

00073 {
00074 #ifdef __MSVC__
00075     return static_cast<int>(GetCurrentThreadId());
00076 #else
00077     return static_cast<int>(pthread_self());
00078 #endif
00079 }

void hexDump ( std::ostream &  o,
void const *  v,
uint  cb,
uint  cbDone 
)

Definition at line 81 of file Memory.cpp.

References min().

Referenced by TuplePrinter::visitBytes().

00082 {
00083     boost::io::ios_all_saver streamStateSaver(o);
00084 
00085     PConstBuffer b = (PConstBuffer) v;
00086     uint cbLine = 16,cbThis;
00087     o.fill('0');
00088     for (; cb; cb -= cbThis, cbDone += cbThis) {
00089         cbThis = std::min(cbLine,cb);
00090         o << std::hex;
00091         o.width(4);
00092         o << cbDone << ": ";
00093         uint i;
00094         for (i = 0; i < cbThis; i++, b++) {
00095             o.width(2);
00096             o << (uint) *b << " ";
00097         }
00098         for (i = cbThis; i < cbLine; i++) {
00099             o << "   ";
00100         }
00101         o << "| ";
00102         for (i = 0, b -= cbThis; i < cbThis; i++, b++) {
00103             if (isprint(*b)) {
00104                 o << *b;
00105             } else {
00106                 o << " ";
00107             }
00108         }
00109         o << std::endl;
00110     }
00111 }

void operator delete[] ( void *  p  )  throw ()

Definition at line 56 of file Memory.cpp.

References free().

00057 {
00058     free(p);
00059 }

void* operator new[] ( unsigned  sz  )  throw (std::bad_alloc)

Definition at line 47 of file Memory.cpp.

00048 {
00049     void *p = malloc(sz ? sz : 1);
00050     if (!p) {
00051         throw std::bad_alloc();
00052     }
00053     return p;
00054 }


Generated on Mon Jun 22 04:00:22 2009 for Fennel by  doxygen 1.5.1