# adn-dodo/custom-hmm architecture

> Architecture diagram of the GitHub repository adn-dodo/custom-hmm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adn-dodo/custom-hmm
- Repository: https://github.com/adn-dodo/custom-hmm

## Overview

HMM is a C heap allocator that manages memory with `sbrk()`. A caller can use its allocator API directly or go through the standard-library wrappers: allocation searches and grows the heap, while freeing coalesces blocks and may trim the heap. The API also provides zeroed allocation, reallocation, and usable-size lookup. The graph reflects the sampled runtime source and README; it omits build and verification machinery. The system-break dependency is explicit, but no source for the external OS service is present.

Main entry points: [`src/heapWrappers.c`](https://github.com/adn-dodo/custom-hmm/blob/main/src/heapWrappers.c) (Standard wrappers), [`src/HmmAlloc.c`](https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c) (Allocate), [`src/HmmFree.c`](https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmFree.c) (Free and coalesce)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Allocator API"]
  node_wrappers["Standard wrappers<br/>[heapWrappers.c]"]
end

subgraph group_engine["Heap engine"]
  node_alloc["Allocate<br/>[HmmAlloc.c]"]
  node_free["Free and coalesce<br/>[HmmFree.c]"]
  node_extras["Calloc, realloc, size<br/>[HmmAlloc.c]"]
end

subgraph group_state["Heap state"]
  node_heapstate[("Blocks and free list<br/>[HmmAlloc.c]")]
end

node_caller(("Application"))
node_systembreak["OS program break"]

node_caller -->|"calls"| node_wrappers
node_wrappers -->|"dispatches malloc"| node_alloc
node_wrappers -->|"dispatches free"| node_free
node_wrappers -->|"dispatches calloc/realloc"| node_extras
node_alloc -->|"searches and updates"| node_heapstate
node_free -->|"coalesces and updates"| node_heapstate
node_extras -->|"allocates"| node_alloc
node_extras -->|"frees on realloc"| node_free
node_alloc -->|"grows with sbrk"| node_systembreak
node_free -->|"trims with sbrk"| node_systembreak

click node_wrappers "https://github.com/adn-dodo/custom-hmm/blob/main/src/heapWrappers.c"
click node_alloc "https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c"
click node_free "https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmFree.c"
click node_extras "https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c"
click node_heapstate "https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_wrappers toneBlue
class node_alloc,node_free,node_extras toneAmber
class node_heapstate toneMint
class node_caller,node_systembreak toneIndigo
```

## Components

### Allocator API

- [Standard wrappers](https://github.com/adn-dodo/custom-hmm/blob/main/src/heapWrappers.c): `src/heapWrappers.c`

### Heap engine

- [Allocate](https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`
- [Free and coalesce](https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmFree.c): `src/HmmFree.c`
- [Calloc, realloc, size](https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`

### Heap state

- [Blocks and free list](https://github.com/adn-dodo/custom-hmm/blob/main/src/HmmAlloc.c): `src/HmmAlloc.c`

### Other components

- **Application**
- **OS program break**

## Connections

- Application → Standard wrappers: calls (evidence: `README.md`)
- Standard wrappers → Allocate: dispatches malloc (evidence: `src/heapWrappers.c`)
- Standard wrappers → Free and coalesce: dispatches free (evidence: `src/heapWrappers.c`)
- Standard wrappers → Calloc, realloc, size: dispatches calloc/realloc (evidence: `src/heapWrappers.c`)
- Allocate → Blocks and free list: searches and updates (evidence: `src/HmmAlloc.c`)
- Free and coalesce → Blocks and free list: coalesces and updates (evidence: `src/HmmFree.c`)
- Calloc, realloc, size → Allocate: allocates (evidence: `src/HmmAlloc.c`)
- Calloc, realloc, size → Free and coalesce: frees on realloc (evidence: `src/HmmAlloc.c`)
- Allocate → OS program break: grows with sbrk (evidence: `src/HmmAlloc.c`)
- Free and coalesce → OS program break: trims with sbrk (evidence: `src/HmmFree.c`)
