c coding style之学习篇
摘要:
1. 使用do-while结构去避免潜在的内存泄漏问题。do { p1 = malloc(10); if (null == p1) { break; } p2 = malloc(20); if (null == p2) { break; } return ok; }while(0);de_init(); return fail;2. 使用指针时必须先检查指针的有效性,这样做的一大好处是可以防止误用null pointer而引起系统crash。if (p1 != null) { do_something(); } else { printf("\nnull pointer... 阅读全文
浙公网安备 33010602011771号