← 返回
效率工具 中文

C

Avoid common C mistakes — memory leaks, buffer overflows, undefined behavior, and pointer traps.
避免常见的C语言错误——内存泄漏、缓冲区溢出、未定义行为及指针陷阱。
ivangdavila
效率工具 clawhub v1.0.1 1 版本 99932.8 Key: 无需
★ 2
Stars
📥 1,446
下载
💾 72
安装
1
版本
#latest

概述

Quick Reference

TopicFile
-------------
malloc/free, leaks, double freememory.md
Null, dangling, pointer arithmeticpointers.md
Null terminator, buffer overflowstrings.md
Integer overflow, signed/unsignedtypes.md
Macro traps, include guardspreprocessor.md
Common undefined behaviorundefined.md

Critical Rules

  • malloc returns void* — cast required in C++, optional in C but check for NULL
  • free(ptr); ptr = NULL; — always null after free to prevent double-free
  • sizeof(array) in function gives pointer size, not array size — pass length separately
  • char str[5] = "hello"; — no room for null terminator, UB when used as string
  • strcpy doesn't check bounds — use strncpy and manually null-terminate
  • Signed overflow is UB — compiler can optimize assuming it never happens
  • i++ + i++ is UB — no sequence point between modifications
  • Returning pointer to local variable — dangling pointer, UB on use
  • #define SQUARE(x) xxSQUARE(1+2) = 1+21+2 = 5, not 9
  • memcpy with overlapping regions — use memmove instead
  • Uninitialized variables — contain garbage, UB if used
  • Array out of bounds — no runtime check, silent corruption or crash

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-29 01:50 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

productivity

Baidu web search

ide-rea
使用百度AI搜索引擎(BDSE)进行网络搜索。适用于获取实时信息、文档资料或研究课题。
★ 239 📥 105,848
productivity

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 446 📥 226,503
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 440 📥 148,314