[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79EY10PD57XZ9NA5CFYGTPH":3,"skill-same:01M79EY10PD57XZ9NA5CFYGTPH":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M79EY10PD57XZ9NA5CFYGTPH","memory-allocators-arenas-c",null,"Design, implement, and verify high-performance custom memory allocators in C and C++. Build Arena \u002F Bump allocators, Pool \u002F Fixed-size block allocators, and Free-List allocators. Ensure strict hardware memory alignment (alignof, power-of-two boundaries), zero-fragmentation lifecycles, and cache line locality. Trigger when building game engines, high-frequency trading (HFT) engines, or embedded runtime systems.","hamzabellouch\u002Fagent-skills","hamzabellouch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F237856042?v=4","01M79BRYW7XAMK3YDWQEMTWGWS","Hamza Bellouch","01M79BRYWXQV3JK2TGVTX8GN2A",8,"MIT","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FProgramming\u002FSystems_and_Hardware\u002FLow_Level_and_Kernel\u002Fmemory-allocators-arenas-c\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: memory-allocators-arenas-c\nmetadata:\n  category: Low-Level Systems Drivers and Kernel\ndescription: Design, implement, and verify high-performance custom memory allocators in C and C++. Build Arena \u002F Bump allocators, Pool \u002F Fixed-size block allocators, and Free-List allocators. Ensure strict hardware memory alignment (alignof, power-of-two boundaries), zero-fragmentation lifecycles, and cache line locality. Trigger when building game engines, high-frequency trading (HFT) engines, or embedded runtime systems.\ncompatibility: C99 \u002F C11, C++17, POSIX \u002F Windows memory primitives\n---\n\n# Custom Memory Allocators & Arenas Skill Guide\n\nThis skill specifies algorithms, pointer arithmetic patterns, and hardware alignment requirements for implementing zero-overhead custom memory allocators in C and C++.\n\n---\n\n## 1. Allocator Topologies & Trade-offs\n\n```text\n+-----------------------+-----------------------+-----------------------+\n| Allocator Type        | Allocation Time       | Deallocation Strategy |\n+-----------------------+-----------------------+-----------------------+\n| Arena (Bump)          | O(1) pointer addition | O(1) Reset all at once|\n| Pool (Fixed-Size)     | O(1) pop free-list    | O(1) push free-list   |\n| Free-List (Segregated)| O(N) or O(log N)      | Coalesce adjacent free|\n+-----------------------+-----------------------+-----------------------+\n```\n\n---\n\n## 2. Production C Implementation: Arena & Pool Allocators\n\n### A. High-Performance Hardware-Aligned Arena Allocator\n\n```c\n#include \u003Cstddef.h>\n#include \u003Cstdint.h>\n#include \u003Cstdlib.h>\n#include \u003Cstdbool.h>\n#include \u003Cassert.h>\n\n#define DEFAULT_ALIGNMENT (sizeof(void*))\n\ntypedef struct {\n    uint8_t *buffer;\n    size_t capacity;\n    size_t offset;\n    size_t prev_offset;\n} MemoryArena;\n\nstatic inline uintptr_t align_forward(uintptr_t ptr, size_t alignment) {\n    assert((alignment & (alignment - 1)) == 0 && \"Alignment must be power of two\");\n    uintptr_t a = (uintptr_t)alignment;\n    return (ptr + a - 1) & ~(a - 1);\n}\n\nvoid arena_init(MemoryArena *arena, void *backing_buffer, size_t capacity) {\n    arena->buffer = (uint8_t*)backing_buffer;\n    arena->capacity = capacity;\n    arena->offset = 0;\n    arena->prev_offset = 0;\n}\n\nvoid *arena_alloc_aligned(MemoryArena *arena, size_t size, size_t alignment) {\n    uintptr_t current_ptr = (uintptr_t)arena->buffer + (uintptr_t)arena->offset;\n    uintptr_t aligned_ptr = align_forward(current_ptr, alignment);\n    size_t padding = aligned_ptr - current_ptr;\n\n    if (arena->offset + padding + size > arena->capacity) {\n        return NULL; \u002F\u002F Out of memory\n    }\n\n    arena->prev_offset = arena->offset;\n    arena->offset += padding + size;\n\n    return (void*)aligned_ptr;\n}\n\nvoid *arena_alloc(MemoryArena *arena, size_t size) {\n    return arena_alloc_aligned(arena, size, DEFAULT_ALIGNMENT);\n}\n\nvoid arena_reset(MemoryArena *arena) {\n    \u002F\u002F Instant O(1) deallocation of all allocated memory\n    arena->offset = 0;\n    arena->prev_offset = 0;\n}\n```\n\n### B. Fixed-Size Block Pool Allocator\n\n```c\ntypedef struct PoolFreeNode {\n    struct PoolFreeNode *next;\n} PoolFreeNode;\n\ntypedef struct {\n    uint8_t *buffer;\n    size_t block_size;\n    size_t capacity;\n    PoolFreeNode *free_list;\n} MemoryPool;\n\nvoid pool_init(MemoryPool *pool, void *backing_buffer, size_t total_size, size_t block_size) {\n    assert(block_size >= sizeof(PoolFreeNode) && \"Block size must fit free node pointer\");\n    pool->buffer = (uint8_t*)backing_buffer;\n    pool->block_size = block_size;\n    pool->capacity = total_size;\n    pool->free_list = NULL;\n\n    \u002F\u002F Chain all blocks into the free list\n    size_t num_blocks = total_size \u002F block_size;\n    for (size_t i = 0; i \u003C num_blocks; ++i) {\n        PoolFreeNode *node = (PoolFreeNode*)(pool->buffer + (i * block_size));\n        node->next = pool->free_list;\n        pool->free_list = node;\n    }\n}\n\nvoid *pool_alloc(MemoryPool *pool) {\n    if (!pool->free_list) {\n        return NULL; \u002F\u002F Pool exhausted\n    }\n    PoolFreeNode *node = pool->free_list;\n    pool->free_list = node->next;\n    return (void*)node;\n}\n\nvoid pool_free(MemoryPool *pool, void *ptr) {\n    if (!ptr) return;\n    PoolFreeNode *node = (PoolFreeNode*)ptr;\n    node->next = pool->free_list;\n    pool->free_list = node;\n}\n```\n\n---\n\n## 3. Best Practices & Hardware Guidelines\n\n1. **Power-of-Two Alignment:** Always enforce that alignments are powers of two (`(align & (align - 1)) == 0`).\n2. **Cache Line Locality:** For high-throughput structs, align to 64 bytes (`alignas(64)`) to avoid false sharing across CPU cores.\n3. **Double Free Elimination:** Arena allocators completely eliminate individual double-free and memory fragmentation bugs because memory is only reclaimed en masse.\n","# Custom Memory Allocators & Arenas Skill Guide\n\nThis skill specifies algorithms, pointer arithmetic patterns, and hardware alignment requirements for implementing zero-overhead custom memory allocators in C and C++.\n\n---\n\n## 1. Allocator Topologies & Trade-offs\n\n```text\n+-----------------------+-----------------------+-----------------------+\n| Allocator Type        | Allocation Time       | Deallocation Strategy |\n+-----------------------+-----------------------+-----------------------+\n| Arena (Bump)          | O(1) pointer addition | O(1) Reset all at once|\n| Pool (Fixed-Size)     | O(1) pop free-list    | O(1) push free-list   |\n| Free-List (Segregated)| O(N) or O(log N)      | Coalesce adjacent free|\n+-----------------------+-----------------------+-----------------------+\n```\n\n---\n\n## 2. Production C Implementation: Arena & Pool Allocators\n\n### A. High-Performance Hardware-Aligned Arena Allocator\n\n```c\n#include \u003Cstddef.h>\n#include \u003Cstdint.h>\n#include \u003Cstdlib.h>\n#include \u003Cstdbool.h>\n#include \u003Cassert.h>\n\n#define DEFAULT_ALIGNMENT (sizeof(void*))\n\ntypedef struct {\n    uint8_t *buffer;\n    size_t capacity;\n    size_t offset;\n    size_t prev_offset;\n} MemoryArena;\n\nstatic inline uintptr_t align_forward(uintptr_t ptr, size_t alignment) {\n    assert((alignment & (alignment - 1)) == 0 && \"Alignment must be power of two\");\n    uintptr_t a = (uintptr_t)alignment;\n    return (ptr + a - 1) & ~(a - 1);\n}\n\nvoid arena_init(MemoryArena *arena, void *backing_buffer, size_t capacity) {\n    arena->buffer = (uint8_t*)backing_buffer;\n    arena->capacity = capacity;\n    arena->offset = 0;\n    arena->prev_offset = 0;\n}\n\nvoid *arena_alloc_aligned(MemoryArena *arena, size_t size, size_t alignment) {\n    uintptr_t current_ptr = (uintptr_t)arena->buffer + (uintptr_t)arena->offset;\n    uintptr_t aligned_ptr = align_forward(current_ptr, alignment);\n    size_t padding = aligned_ptr - current_ptr;\n\n    if (arena->offset + padding + size > arena->capacity) {\n        return NULL; \u002F\u002F Out of memory\n    }\n\n    arena->prev_offset = arena->offset;\n    arena->offset += padding + size;\n\n    return (void*)aligned_ptr;\n}\n\nvoid *arena_alloc(MemoryArena *arena, size_t size) {\n    return arena_alloc_aligned(arena, size, DEFAULT_ALIGNMENT);\n}\n\nvoid arena_reset(MemoryArena *arena) {\n    \u002F\u002F Instant O(1) deallocation of all allocated memory\n    arena->offset = 0;\n    arena->prev_offset = 0;\n}\n```\n\n### B. Fixed-Size Block Pool Allocator\n\n```c\ntypedef struct PoolFreeNode {\n    struct PoolFreeNode *next;\n} PoolFreeNode;\n\ntypedef struct {\n    uint8_t *buffer;\n    size_t block_size;\n    size_t capacity;\n    PoolFreeNode *free_list;\n} MemoryPool;\n\nvoid pool_init(MemoryPool *pool, void *backing_buffer, size_t total_size, size_t block_size) {\n    assert(block_size >= sizeof(PoolFreeNode) && \"Block size must fit free node pointer\");\n    pool->buffer = (uint8_t*)backing_buffer;\n    pool->block_size = block_size;\n    pool->capacity = total_size;\n    pool->free_list = NULL;\n\n    \u002F\u002F Chain all blocks into the free list\n    size_t num_blocks = total_size \u002F block_size;\n    for (size_t i = 0; i \u003C num_blocks; ++i) {\n        PoolFreeNode *node = (PoolFreeNode*)(pool->buffer + (i * block_size));\n        node->next = pool->free_list;\n        pool->free_list = node;\n    }\n}\n\nvoid *pool_alloc(MemoryPool *pool) {\n    if (!pool->free_list) {\n        return NULL; \u002F\u002F Pool exhausted\n    }\n    PoolFreeNode *node = pool->free_list;\n    pool->free_list = node->next;\n    return (void*)node;\n}\n\nvoid pool_free(MemoryPool *pool, void *ptr) {\n    if (!ptr) return;\n    PoolFreeNode *node = (PoolFreeNode*)ptr;\n    node->next = pool->free_list;\n    pool->free_list = node;\n}\n```\n\n---\n\n## 3. Best Practices & Hardware Guidelines\n\n1. **Power-of-Two Alignment:** Always enforce that alignments are powers of two (`(align & (align - 1)) == 0`).\n2. **Cache Line Locality:** For high-throughput structs, align to 64 bytes (`alignas(64)`) to avoid false sharing across CPU cores.\n3. **Double Free Elimination:** Arena allocators completely eliminate individual double-free and memory fragmentation bugs because memory is only reclaimed en masse.\n",{"name":5,"metadata":24,"description":7,"compatibility":26},{"category":25},"Low-Level Systems Drivers and Kernel","C99 \u002F C11, C++17, POSIX \u002F Windows memory primitives","main","e905af21e5f1e1c3ca605e9656c3a7930360a84e","Programming\u002FSystems_and_Hardware\u002FLow_Level_and_Kernel\u002Fmemory-allocators-arenas-c",1,"https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills","https:\u002F\u002Fhamzabellouch.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fhamzabellouch","hamzabellouch.github.io","CEO & Founder of @tknoglobal | Researcher in Technology & Applied Sciences.","2026-10-17 03:20:19",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add hamzabellouch\u002Fagent-skills --skill memory-allocators-arenas-c",{"tool":43,"command":44},"bunx","bunx skills add hamzabellouch\u002Fagent-skills --skill memory-allocators-arenas-c",{"tool":46,"command":47},"pnpm","pnpm dlx skills add hamzabellouch\u002Fagent-skills --skill memory-allocators-arenas-c","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FProgramming\u002FSystems_and_Hardware\u002FLow_Level_and_Kernel\u002Fmemory-allocators-arenas-c\u002FSKILL.md",true,[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M79FHH2H815A9TAP6WNKH4Q8","security-audit","Comprehensive security guidance, source code audit, vulnerability assessment, and penetration test review for codebases, APIs, microservices, CLI tools, libraries, and LLM-backed applications. Triggers on requests to audit a codebase, conduct security reviews, find vulnerabilities or flaws, pen-test source code, or when the user asks in Arabic (فحص أمني، تدقيق الكود أمنياً، مراجعة الثغرات، فحص أمان المشروع). Supports Guidance mode (focused review) and Full Audit mode (deterministic 6-phase harness).","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FSecurity_Audit_and_Code_Review\u002Fsecurity-audit\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M79FHBGXVBY6VQ1X7ETAZMF1","malware-analysis-reversing","Production malware analysis workflows, reverse engineering methodologies, isolated sandbox triage, static\u002Fdynamic binary analysis, memory forensics, and YARA detection rule authoring.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fmalware-analysis-reversing\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M79FH6EACDR801TZCE4R8SAC","application-security-pentesting","Production Application Security (AppSec) standards, OWASP Top 10 vulnerability remediation, SAST\u002FDAST pipeline integration, secure code review, threat modeling, and defensive security posture.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fapplication-security-pentesting\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M79FH0VKVT44FK923K520ZQA","oauth2-oidc-security-flows","Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M79FGVVB3R4T88XXD8FRSV5B","jwt-session-management-hardening","Harden JWT-based authentication and session lifecycles using asymmetric signing (RS256\u002FEdDSA), JWKS rotation, strict claims validation, Redis-backed sliding window sessions, revocation lists, and secure HttpOnly cookie storage. Trigger when implementing token validation, session revocation, or hardening API authentication.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79FGNCPZ85CVEY0B3NE4H3B","soc2-compliance-automation","Best practices for implementing SOC 2 Type II compliance controls, continuous evidence collection, infrastructure policy-as-code, and automated security monitoring. Use when automating Trust Services Criteria (Security, Availability, Confidentiality, Processing Integrity, Privacy), audit logging, IAM least privilege, or CI\u002FCD security gates.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FGovernance_Compliance_and_Legal_Tech\u002Fsoc2-compliance-automation\u002FSKILL.md",[],[]]