diff --git a/qfetchC-notes.md b/qfetchC-notes.md index dd27df3..bd0c98a 100644 --- a/qfetchC-notes.md +++ b/qfetchC-notes.md @@ -21,8 +21,8 @@ C standard libraries hide some functions unless you *opt in*. Without it: -* Some systems won’t expose those functions -* You’ll get mysterious warnings or missing symbols + - Some systems won’t expose those functions + - You’ll get mysterious warnings or missing symbols --- @@ -37,8 +37,8 @@ Without it: In C: -* Headers are **contracts** -* If it’s not included, the compiler assumes *nothing* + - Headers are **contracts** + - If it’s not included, the compiler assumes *nothing* **Rule of thumb:** @@ -58,9 +58,9 @@ Example: ### What this teaches you -* C has **no runtime reflection** -* Portability happens at **compile time** -* The preprocessor literally removes code before compilation + - C has **no runtime reflection** + - Portability happens at **compile time** + - The preprocessor literally removes code before compilation Think of it as: @@ -82,11 +82,11 @@ static char *dup_or_unknown(const char *s) This function enforces a **contract**: -* Every getter: + - Every getter: - * returns a valid `char *` - * never returns `NULL` - * always returns heap memory + - returns a valid `char *` + - never returns `NULL` + - always returns heap memory ### Why that matters @@ -124,9 +124,9 @@ Rules being followed: Contrast this with C++: -* No destructors -* No smart pointers -* No safety net + - No destructors + - No smart pointers + - No safety net --- @@ -140,15 +140,15 @@ static char buf[256]; But that would: -* Break thread safety -* Break reentrancy -* Make functions non-composable + - Break thread safety + - Break reentrancy + - Make functions non-composable Dynamic allocation makes your functions: -* Reusable -* Testable -* Library-quality + - Reusable + - Testable + - Library-quality --- @@ -163,9 +163,9 @@ Each platform teaches a lesson: /proc/uptime ``` -* Text parsing -* Line-by-line scanning -* Defensive string handling + - Text parsing + - Line-by-line scanning + - Defensive string handling ### macOS / BSD @@ -173,9 +173,9 @@ Each platform teaches a lesson: sysctl() ``` -* Structured kernel APIs -* Buffer-size negotiation -* Integer & struct-based data + - Structured kernel APIs + - Buffer-size negotiation + - Integer & struct-based data --- @@ -188,9 +188,9 @@ difftime(now, boottime.tv_sec); Why this matters: -* `time_t` may not be an integer -* You *never* subtract times directly -* `difftime()` handles portability + - `time_t` may not be an integer + - You *never* subtract times directly + - `difftime()` handles portability --- @@ -204,10 +204,10 @@ free(user); Notice: -* No logic -* No parsing -* No platform checks -* No error handling clutter + - No logic + - No parsing + - No platform checks + - No error handling clutter All complexity lives *outside* `main()`.