为什么使用“strlen30()"?而不是“strlen()"? [英] Why use "strlen30()" instead of "strlen()"?

查看:35
本文介绍了为什么使用“strlen30()"?而不是“strlen()"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读并想知道sqlite的源代码

I've read and wondered about the source code of sqlite

static int strlen30(const char *z){
  const char *z2 = z;
  while( *z2 ){ z2++; }
  return 0x3fffffff & (int)(z2 - z);
}

为什么使用 strlen30() 而不是 strlen()(在 string.h 中)??

Why use strlen30() instead of strlen() (in string.h)??

推荐答案

提交消息 包含此更改状态:

[793aaebd8024896c] 部分签入 [c872d55493] 永远不要使用 strlen().使用我们自己的内部 sqlite3Strlen30() 保证永远不会溢出整数.额外的显式转换以避免令人讨厌的警告消息.(CVS 6007)(用户:drh 分支:trunk)

[793aaebd8024896c] part of check-in [c872d55493] Never use strlen(). Use our own internal sqlite3Strlen30() which is guaranteed to never overflow an integer. Additional explicit casts to avoid nuisance warning messages. (CVS 6007) (user: drh branch: trunk)

这篇关于为什么使用“strlen30()"?而不是“strlen()"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆