How can I know where the segment of memory is all Zero?

I mean, I malloc a segment of memory, maybe 1k maybe 20bytes.. assume the pointer is pMem How can I know the content pMem refered is all Zero or \0 . I know memcmp but the second parameter should another memory address... thanx

Simple. memset(3) it to zero.

size_t is_all_zero( void *location, size_t len)
{
     unsigned char *p=(unsigned char *)location;
     while( len && ! *p)
      {
          p++;
          len--;
      }
      return len; 
}

returns zero when len bytes at location are all zero.

If you use calloc it will initialize all memory locations to zero before returning.

Never guess or hope. If you want it zeroed, zero it yourself(which is just as fast as checking it). Even if seems to always be zero right now, that may change when you start doing repeated malloc() and free() to the point you get bits of memory you've used before.