|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #ifndef _SMALLOC_H
- #define _SMALLOC_H
-
- #include <stddef.h>
- #include <stdint.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- struct smalloc_pool;
-
- typedef size_t (*smalloc_oom_handler)(struct smalloc_pool *, size_t);
-
-
- struct smalloc_pool {
- void *pool;
- size_t pool_size;
- int do_zero;
- smalloc_oom_handler oomfn;
- };
-
-
- extern struct smalloc_pool smalloc_curr_pool;
-
- #ifdef ARDUINO_TEENSY41
- extern struct smalloc_pool extmem_smalloc_pool;
- #endif
-
-
- typedef void (*smalloc_ub_handler)(struct smalloc_pool *, const void *);
-
- void sm_set_ub_handler(smalloc_ub_handler);
-
- int sm_align_pool(struct smalloc_pool *);
- int sm_set_pool(struct smalloc_pool *, void *, size_t, int, smalloc_oom_handler);
- int sm_set_default_pool(void *, size_t, int, smalloc_oom_handler);
- int sm_release_pool(struct smalloc_pool *);
- int sm_release_default_pool(void);
-
-
-
- void *sm_malloc_pool(struct smalloc_pool *, size_t);
- void *sm_zalloc_pool(struct smalloc_pool *, size_t);
- void sm_free_pool(struct smalloc_pool *, void *);
-
- void *sm_realloc_pool(struct smalloc_pool *, void *, size_t);
- void *sm_realloc_move_pool(struct smalloc_pool *, void *, size_t);
- void *sm_calloc_pool(struct smalloc_pool *, size_t, size_t);
-
- int sm_alloc_valid_pool(struct smalloc_pool *spool, const void *p);
-
- size_t sm_szalloc_pool(struct smalloc_pool *, const void *);
- int sm_malloc_stats_pool(struct smalloc_pool *, size_t *, size_t *, size_t *, int *);
-
-
-
- void *sm_malloc(size_t);
- void *sm_zalloc(size_t);
- void sm_free(void *);
-
- void *sm_realloc(void *, size_t);
- void *sm_realloc_move(void *, size_t);
- void *sm_calloc(size_t, size_t);
-
- int sm_alloc_valid(const void *p);
-
- size_t sm_szalloc(const void *);
-
- int sm_malloc_stats(size_t *, size_t *, size_t *, int *);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
|