计算c字符的长度,保证不超过2^30_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > 计算c字符的长度,保证不超过2^30

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

 2016/10/23 5:30:52  huahuahu  程序员俱乐部  我要评论(0)
  • 摘要:来自sqlite3源码/***Computeastringlengththatislimitedtowhatcanbestoredin**lower30bitsofa32-bitsignedinteger.****Thevaluereturnedwillneverbenegative.Norwilliteverbegreater**thantheactuallengthofthestring.Forverylongstrings(greater**than1GiB
  • 标签:

来自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);
}
  • 相关文章
发表评论
用户名: 匿名