

# Core

Core runtime and utility facilities.

### Classes

| Name | Description |
|------|-------------|
| [`Arena`](#arena) | Linear allocation arena. |

### Typedefs

| Return | Name | Description |
|--------|------|-------------|
| `void` | [`printnum_fn`](#printnum_fn)  |  |

---

#### printnum_fn

```cpp
void printnum_fn()
```

### Functions

| Return | Name | Description |
|--------|------|-------------|
| `int` | [`add`](#add)  | Adds two integers. |
| `int` | [`main`](#main)  | Runs a small JIT flow and prints a hello-world message. |
| `void` | [`arena_init`](#arena_init) `static` `inline` | Initializes an arena with fixed capacity. |
| `void *` | [`arena_alloc`](#arena_alloc) `static` `inline` | Allocates aligned memory from the arena. |
| `void` | [`arena_free`](#arena_free) `static` `inline` | Releases arena buffer and resets state. |

---

#### add

```cpp
int add(int a, int b)
```

Adds two integers.

#### Parameters
* `a` First integer. 

* `b` Second integer. 

#### Returns
The sum of a and b.

---

#### main

```cpp
int main()
```

Runs a small JIT flow and prints a hello-world message.

#### Returns
Process exit code.

---

#### arena_init

`static` `inline`

```cpp
static inline void arena_init(Arena * a, size_t cap)
```

Initializes an arena with fixed capacity.

#### Parameters
* `a` [Arena](#arena) to initialize. 

* `cap` Buffer capacity in bytes.

---

#### arena_alloc

`static` `inline`

```cpp
static inline void * arena_alloc(Arena * a, size_t size)
```

Allocates aligned memory from the arena.

#### Parameters
* `a` [Arena](#arena) to allocate from. 

* `size` Requested byte size. 

#### Returns
Pointer to allocated storage inside the arena.

---

#### arena_free

`static` `inline`

```cpp
static inline void arena_free(Arena * a)
```

Releases arena buffer and resets state.

#### Parameters
* `a` [Arena](#arena) to release.



## Arena

```cpp
#include <arena.h>
```

Linear allocation arena.

### Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| `char *` | [`buf`](#buf)  | Backing buffer for all allocations. |
| `size_t` | [`used`](#used)  | Number of bytes currently consumed. |
| `size_t` | [`cap`](#cap)  | Total arena capacity in bytes. |

---

#### buf

```cpp
char * buf
```

Backing buffer for all allocations.

---

#### used

```cpp
size_t used
```

Number of bytes currently consumed.

---

#### cap

```cpp
size_t cap
```

Total arena capacity in bytes.

