29 lines
755 B
C
29 lines
755 B
C
#ifndef SCRATCHPAD_H
|
|
#define SCRATCHPAD_H
|
|
|
|
#include "../allocator-interface/allocator-interface.h"
|
|
#include <stddef.h>
|
|
|
|
typedef struct Scratchpad_s {
|
|
void* memory;
|
|
size_t capacity;
|
|
size_t reserved;
|
|
struct Scratchpad_s* next;
|
|
allocator_t* allocator;
|
|
} Scratchpad;
|
|
|
|
/*!
|
|
@brief Create a new Scratchpad Buffer
|
|
@param target this
|
|
@param capacity How many bytes the buffer should hold initially
|
|
@return EXIT_SUCCESS, ENOMEM, EDESTADDRREQ
|
|
*/
|
|
int Scratchpad_Create(Scratchpad* target, size_t capacity, allocator_t* allocator);
|
|
|
|
void* Scratchpad_Reserve(Scratchpad* pad, size_t size);
|
|
int Scratchpad_Reclaim(Scratchpad* pad, void* pointer, size_t length);
|
|
void Scratchpad_Reset(Scratchpad* pad);
|
|
|
|
void Scratchpad_Destroy(Scratchpad* pad);
|
|
|
|
#endif
|