计算c字符的长度,保证不超过2^30

来自sqlite3源码

/*
** Compute a string length that is limited to what can be stored in
** lower 30 bits of a 32-bit signed integer.
**
** The value returned will never be negative.  Nor will it ever be greater
** than the actual length of the string.  For very long strings (greater
** than 1GiB) the value returned might be less than the true string length.
*/
int sqlite3Strlen30(const char *z){
  if( z==0 ) return 0;
  return 0x3fffffff & (int)strlen(z);
}

posted on 2016-10-22 23:17  花老🐯  阅读(530)  评论(0编辑  收藏  举报

导航