Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
Borg3
85 days ago
|
parent
|
context
|
favorite
| on:
Improvements to static analysis in GCC 14
#define strncpyz(d,s,l) *(strncpy(d,s,l)+(l))=0
Of course this one is unsafe for macro expansion. But well, its C :)
teo_zero
84 days ago
[–]
I'd rather put the final nul at d+l-1 than at d+l, so that l can be the size of d, not "one more than the size of d":
strncpyz(buf,src,sizeof buf);
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
Of course this one is unsafe for macro expansion. But well, its C :)