Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/klib/blob/master/kbarena.h # klib [Ported from github.com/attractivechaos/klib] added block arena Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `klib / kbarena.h` 46 lines ยท 921 bytes Raw Blame History 1 #ifndef AC_KBARENA_H 2 #define AC_KBARENA_H 3 4 #include 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 /** 11 * Initialize a blocked arena 12 * 13 * @param blen block length in bytes 14 * 15 * @return pointer to a blocked arena 16 */ 17 void *kba_init(unsigned blen); 18 19 /** Destroy a blocked arena */ 20 void kba_destroy(void *kba); 21 22 /** 23 * Allocate memory from a blocked arena 24 * 25 * @param len size of the memory to allocate 26 * @param aln alignment; must be power of 2 27 * 28 * @return pointer to the memory on success; NULL on insufficient memory or 29 * when len is longer than block length 30 */ 31 void *kba_alloc(void *kba, unsigned len, unsigned aln); 32 33 /** Save the state */ 34 int kba_save(void *kba); 35 36 /** Restore the state (effectively free all memory allocated after the pairing save) */ 37 int kba_restore(void *kba); 38 39 /** Get the capacity in byte */ 40 size_t kba_capacity(const void *ba_); 41 42 #ifdef __cplusplus 43 } 44 #endif 45 46 #endif