| name | is-coding-rules-c |
| description | C/blk coding rules for the Intersec codebase. Load before writing or reviewing C or blk code. |
Intersec C Coding Rules
Error-handling macros (core/macros.h)
RETHROW(e)
RETHROW_P(e)
THROW_ERR_UNLESS(cond)
THROW_FALSE_IF(cond)
RETHROW / RETHROW_P are expressions that evaluate to e on success, so
use them inline: x = RETHROW(foo());.
Use these instead of explicit if checks when no cleanup is needed before
returning. When cleanup is required, use explicit if + goto cleanup,
or the defer macro (see core/macros.h).
Forbidden functions
- Memory:
malloc, free, realloc, calloc, alloca — use
p_new/p_delete/p_realloc (heap) or the mp_* pool
equivalents.
- Strings:
strncpy, strcpy, strcat, sprintf, gets, strtok
— no single replacement; pick per context: sb_t builder
(sb_add*, sb_addf), pstream_t reader, or snprintf for
bounded writes into a plain buffer.