libcsdbg  1.28
C++ exception (and generic) stack trace debug library
void * csdbg::util::memset ( void *  mem,
u8  val,
u32  sz 
)
static

Fill a memory block with a constant byte.

Parameters
[in,out]memthe base address of the block
[in]valthe byte
[in]szthe block size
Returns
the first argument
Note
This method is used for portability (in place of BSD's bzero)

Definition at line 320 of file util.cpp.

References __D_ASSERT, likely, and unlikely.

Referenced by csdbg::sttybuf::config(), csdbg::filter::filter(), csdbg::tcpsockbuf::open(), and csdbg::string::shred().

321 {
322  __D_ASSERT(mem != NULL);
323  if ( unlikely(mem == NULL) )
324  return mem;
325 
326  u8 *p = static_cast<u8*> (mem);
327  while ( likely(sz-- > 0) )
328  *(p++) = val;
329 
330  return mem;
331 }
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
unsigned char u8
8-bit unsigned integer
Definition: config.hpp:92
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268

+ Here is the caller graph for this function: