memory-safety-patterns

Installation
Summary

Memory-safe programming patterns for RAII, ownership, smart pointers, and resource management across Rust, C++, and C.

  • Covers six core memory bug categories (use-after-free, double-free, leaks, buffer overflow, dangling pointers, data races) with language-specific prevention strategies
  • Provides RAII patterns in C++ with destructors, lock guards, and transactions; smart pointer guidance (unique_ptr, shared_ptr, weak_ptr) with custom deleters
  • Implements Rust ownership, borrowing, lifetimes, and interior mutability (Cell, RefCell, Rc, Arc) with compile-time safety guarantees
  • Includes safe C patterns using goto cleanup, opaque pointers with create/destroy pairs, and GCC cleanup attributes
  • Demonstrates bounds checking via containers and spans in C++, and iterators in Rust; thread-safe patterns using atomics, mutexes, and RwLock across languages
SKILL.md

Memory Safety Patterns

Cross-language patterns for memory-safe programming including RAII, ownership, smart pointers, and resource management.

When to Use This Skill

  • Writing memory-safe systems code
  • Managing resources (files, sockets, memory)
  • Preventing use-after-free and leaks
  • Implementing RAII patterns
  • Choosing between languages for safety
  • Debugging memory issues

Core Concepts

1. Memory Bug Categories

Bug Type Description Prevention
Related skills

More from wshobson/agents

Installs
6.9K
Repository
wshobson/agents
GitHub Stars
35.3K
First Seen
Jan 20, 2026