finished formatting md file

This commit is contained in:
anihilis 2026-01-20 09:21:22 -08:00
parent f8b6995add
commit f20b2d9e22

View file

@ -21,8 +21,8 @@ C standard libraries hide some functions unless you *opt in*.
Without it:
* Some systems wont expose those functions
* Youll get mysterious warnings or missing symbols
- Some systems wont expose those functions
- Youll get mysterious warnings or missing symbols
---
@ -37,8 +37,8 @@ Without it:
In C:
* Headers are **contracts**
* If its not included, the compiler assumes *nothing*
- Headers are **contracts**
- If its 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()`.