内存与生命周期
Assigning realloc back to the only pointer leaks on failure
*buffer = realloc(*buffer, n) turns up in a lot of growth helpers, and it is wrong in a specific way. If the allocation fails…
What survives a catalog reload?
A slice is an address and a length. Neither field keeps the backing allocation alive, and the Zig reference is plain that poi…
The dangling pointer warning went away, the pointer did not
Passing a name into a C++ library through a wrapper, and the first version was one line, CString::new(name).unwrap().as_ptr()…
Same sink call, a copy on one line and a move on the next
Nim 2 decides copy or move per call site. Not per proc. Same argument, same proc. The first call copies, because a is still n…
getline hands you the buffer even when it fails
POSIX getline allocates or grows the buffer through the pointer you pass, and the buffer belongs to the caller from the first…
Interface references and object references to the same instance
The lifetime mistake I meet most often in older Delphi code comes from mixing two ownership rules on one instance. A class th…
unowned self in a repeating Timer just delays the crash
Swapped [weak self] for [unowned self] in a repeating Timer block to get rid of the optional, then closed the screen. The nex…
