aboutsummaryrefslogtreecommitdiff
path: root/block_walker.h
blob: 00efc097419aea7a6dd85636082af9554f0ee7dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef _BLOCK_WALKER_H
#define _BLOCK_WALKER_H
#include <stdint.h>

typedef struct _block_walker bwalker;

/* Creacion y destruccion */
bwalker *bwalker_create(const char *base_mem,size_t size, uint16_t *indirect_mem);
void bwalker_destroy (bwalker *bw);

/* Consigue un bloque libre. En caso de fallar, retorna 0 */
uint16_t bwalker_direct_length(bwalker *bw);
uint16_t bwalker_indirect_length(bwalker *bw);

uint16_t bwalker_allocate_block(bwalker *bw);
void bwalker_free_block(bwalker *bw);

uint16_t bwalker_next(bwalker *bw);
uint16_t bwalker_prev(bwalker *bw);
uint16_t bwalker_last_indirect (bwalker *bw);
uint16_t bwalker_last_block (bwalker *bw);
uint16_t bwalker_block_is_last(bwalker *bw);

void bwalker_set_first(bwalker *bw);
#endif