src/lib/util.c
bool is_buf_zero(const char *buf, int len)
{
   uint64_t *ip;
   const char *p;
   int i, len64, done, rem;

   if (buf[0] != 0) {
      return false;
   }
   ip = (uint64_t *)buf;
   /* Optimize by checking uint64_t for zero */
   len64 = len / sizeof(uint64_t);
   for (i=0; i < len64; i++) {
      if (ip[i] != 0) {
         return false;
      }
   }
   done = len64 * sizeof(uint64_t);  /* bytes already checked */
   p = buf + done;
   rem = len - done;
   for (i = 0; i < rem; i++) {
      if (p[i] != 0) {
         return false;
      }
   }
   return true;
}
/* Return true of buffer has all zero bytes */
Return true of buffer has all zero bytes
Return true of buffer has all zero bytes
bool is_buf_zero(const char *buf, int len)
{
   uint64_t *ip;
   const char *p;
   int i, len64, done, rem;
   if (buf[0] != 0) {
      return false;
   }
   ip = (uint64_t *)buf;
   len64 = len / sizeof(uint64_t);
   for (i=0; i < len64; i++) {
      if (ip[i] != 0) {
         return false;
      }
   }
   done = len64 * sizeof(uint64_t);  
   p = buf + done;
   rem = len - done;
   for (i = 0; i < rem; i++) {
      if (p[i] != 0) {
         return false;
      }
   }
   return true;
}
bool is_buf_zero ( const char * buf , int len ) { uint64_t * ip ; const char * p ; int i , len64 , done , rem ; if ( buf [ 0 ] != 0 ) { return false ; } ip = ( uint64_t * ) buf ; len64 = len / sizeof ( uint64_t ) ; for ( i = 0 ; i < len64 ; i ++ ) { if ( ip [ i ] != 0 ) { return false ; } } done = len64 * sizeof ( uint64_t ) ; p = buf + done ; rem = len - done ; for ( i = 0 ; i < rem ; i ++ ) { if ( p [ i ] != 0 ) { return false ; } } return true ; }
Return true of buffer has all zero bytes
Return true of buffer has all zero bytes
/* Optimize by checking uint64_t for zero */ /* bytes already checked */