c-patterns
C language patterns and best practices for safe, maintainable C: ownership, API contracts, error handling, integer safety, portability, and concurrency boundaries. Use when writing or reviewing C code (C11+), designing module interfaces, refactoring legacy C, or hardening low-level code paths.
v2026.11.13-21cd5683 instalaciones+3 en 7 días39 EstrellasMITsincronizado hace 10 horas
Instalar
¿Aún no tienes la CLI de NotHoly? Instálala primero.
$ curl -fsSL https://notholy.com/install.sh | sh$ notholy skills install aeondave/c-patternsEscribe en ~/.notholy/skills después de comprobar la firma y el SHA-256.
FirmaFirmado, ed25519
Paqueteb0109b83…268f6460
b0109b832435…6e0b268f64606 archivos · 7.3 KBEscaneoBajo1 hallazgo
- Enlaces a dominios externos
Fuentegithub.com/AeonDave/malskill/tree/main/coding/c-patterns@21cd568
Esta entrada todavía no está escrita en tu idioma, así que aparece en English.
En esta página
This skill focuses on safe C: explicit ownership, explicit errors, predictable control flow, and contracts that survive refactors.
If you’re writing tests, use c-testing.
When to activate
- Writing/refactoring C modules and APIs
- Reviewing for memory safety and integer safety
- Designing error-handling conventions and cleanup paths
- Hardening code for sanitizer/static analysis adoption
- Porting C code across GCC/Clang/MSVC/MinGW
Core rules (high signal)
- Make ownership explicit: allocate/free at the same abstraction level.
- Use a consistent error strategy (return codes, out-params) and document it in headers.
- Avoid in-band error indicators when possible.
- Use a single-exit cleanup path for functions managing multiple resources.
- Treat integer conversions and size calculations as potential bugs.
Recommended workflow
Phase 1 — Define API contract first
Before coding:
- Define ownership of every pointer parameter (
borrowed,owned,transferred). - Define preconditions/postconditions in the header, not only in comments inside
.c. - Define error domain (
enumor code space) and whethererrnois used.
Phase 2 — Implement with explicit lifetimes
- Use
create/destroy,init/deinit, oropen/closepairs consistently. - Keep one cleanup exit path for multi-resource functions.
- Do not mix allocator families (
malloc/freevs custom pool vs Win32 heaps).
Phase 3 — Harden integer and bounds logic
- Use
size_tfor sizes/counts and guard all multiplication/addition used in allocation. - Validate all signed/unsigned conversions and indexing arithmetic.
- Reject impossible sizes early (
n == 0,n > MAX_ALLOWED, overflow guards).
Phase 4 — Concurrency boundaries
- Prefer immutable data or message passing where possible.
- If locks are needed, document lock ownership and lock order in header comments.
- Use atomics for single-value state; mutexes for compound invariants.
Phase 5 — Toolchain-aware portability
- Keep warning set strict on all compilers (GCC/Clang/MSVC).
- Avoid UB-dependent behavior and compiler-specific assumptions.
- Guard compiler-specific attributes/macros with feature checks.
Quick review checklist
- Every pointer has clear ownership semantics in the API.
- Every non-trivial function has deterministic cleanup path.
- Every allocation arithmetic path has overflow guard.
- Every error path returns actionable status.
- Concurrency primitives protect explicitly documented data.
- Code builds clean with strict warnings on at least two toolchains.
Resources
Load on demand:
references/error-handling.md— error policy, return codes, cleanup patternsreferences/memory-ownership.md— allocation/free rules, zero-length alloc, free-nullreferences/integers.md— overflow, size_t usage, bounds checkingreferences/concurrency.md— pthreads, C11 atomics, Win32 threads, race detectionreferences/tooling.md— warnings, sanitizers, static analysis, binary inspection (MinGW/objdump, MSVC/dumpbin, Linux tools)
Archivos de esta versión
references/513.2 KB
- concurrency.md3.4 KB
- error-handling.md2.1 KB
- integers.md1.9 KB
- memory-ownership.md2.0 KB
- tooling.md3.9 KB
- SKILL.md3.7 KB
Permisos
| Permiso | Declarado | Hallado en el escaneo |
|---|---|---|
| Lee archivos | No | No |
| Escribe archivos | No | No |
| Ejecuta comandos de shell | Sí | Sí |
| Usa la red | Sí | Sí |
| Usa conectores | No | No |
| Controla un navegador | No | No |
Hallazgos del escaneo
Revisado el 13 nov 2026
- InfoEnlace · Enlaces a dominios externos
Un escaneo limpio baja el riesgo, pero no prueba que el paquete sea seguro. Lee lo que instalas.
| Versión | Publicada | Commit | SHA-256 | Firma | Cambio de permisos |
|---|---|---|---|---|---|
| v2026.11.13-21cd568 | 13 nov 2026 | 21cd568 | b0109b83 | Firmada | – |
Más de AeonDave
Todo de este publicadorMás en Linux, cloud y contenedores
Ver la categoría- detecting-aws-credential-exposure-with-trufflehogmukul975/detecting-aws-credential-exposure-with-trufflehog5
- cloud-gcpnoorqureshi/cloud-gcp4
- container-image-hardeningsecurityskills/container-image-hardening3
- performing-cloud-incident-containment-proceduresmukul975/performing-cloud-incident-containment-procedures3
- implementing-taxii-server-with-opentaxiimukul975/implementing-taxii-server-with-opentaxii3
- detecting-cryptomining-in-cloudmukul975/detecting-cryptomining-in-cloud3
Pregunta todo lo que tu alcance permite.
Crea la cuenta, añade créditos y haz la primera pregunta en el chat o en la terminal.
- 1/3
Crea la cuenta
Individual o empresa. Puedes pasar a empresa después sin perder saldo ni claves.
IndividualEmpresa - 2/3
Añade créditos
Con tarjeta. Pagas por token, sin suscripción.
$5.00recarga mínima - 3/3
Pregunta
En el chat, o instala el CLI y ejecuta notholy login en tu terminal.
$ notholy login