From f823968941f88b0a57f8f440af54be624b8f0ef6 Mon Sep 17 00:00:00 2001 From: SongXiangYing Date: Wed, 21 Jan 2026 16:10:08 +0800 Subject: [PATCH] no message --- b.cpp | 34 ++++++++++++++++++++++++++++++++++ c.cpp | 5 +++++ 测试git.txt | 0 3 files changed, 39 insertions(+) create mode 100644 b.cpp create mode 100644 c.cpp create mode 100644 测试git.txt diff --git a/b.cpp b/b.cpp new file mode 100644 index 0000000..0bdd570 --- /dev/null +++ b/b.cpp @@ -0,0 +1,34 @@ +void f1(struct fred_t *p) +{ + // dereference p and then check if it's NULL + int x = p->x; + if (p) + do_something(x); +} + +void f2() +{ + const char *p = NULL; + for (int i = 0; str[i] != '\0'; i++) + { + if (str[i] == ' ') + { + p = str + i; + break; + } + } + + // p is NULL if str doesn't have a space. If str always has a + // a space then the condition (str[i] != '\0') would be redundant + return p[1]; +} + +void f3(int a) +{ + struct fred_t *p = NULL; + if (a == 1) + p = fred1; + + // if a is not 1 then p is NULL + p->x = 0; +} \ No newline at end of file diff --git a/c.cpp b/c.cpp new file mode 100644 index 0000000..da05479 --- /dev/null +++ b/c.cpp @@ -0,0 +1,5 @@ +void f() +{ + char *p; + *p = 0; +} diff --git a/测试git.txt b/测试git.txt new file mode 100644 index 0000000..e69de29