摘要: C语言一个内存分配引发的问题——指针长度截断 问题现象 #include <stdio.h> #include <string.h> int main() { char* str = NULL; str = (char*)calloc(1, 5); fprintf(stderr, str); ret 阅读全文
posted @ 2025-05-07 16:52 3的4次方 阅读(38) 评论(0) 推荐(0)
摘要: C语言ALIGN对齐数宏 Linux内核中有许多 ALIGN 宏,如: #define ALIGN(x, size) __ALIGN_MASK(x,(typeof(x))(size)-1) // typeof宏是gcc的扩展,用于求出x的类型 #define __ALIGN_MASK(x,mask) 阅读全文
posted @ 2025-05-07 10:32 3的4次方 阅读(70) 评论(0) 推荐(0)