38 lines
781 B
C
38 lines
781 B
C
|
|
#pragma once
|
||
|
|
#include <stddef.h>
|
||
|
|
#include <stdint.h>
|
||
|
|
#include "hakmem.h"
|
||
|
|
#include "hakmem_tiny.h"
|
||
|
|
#include "hakmem_super_registry.h"
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
// HAKX Tiny front: minimal fast path on top of HAKMEM Tiny
|
||
|
|
#define HAKX_TINY_FRONT_MAX 128u
|
||
|
|
|
||
|
|
__attribute__((always_inline))
|
||
|
|
static inline int hakx_tiny_can_handle(size_t size) {
|
||
|
|
return (size <= HAKX_TINY_FRONT_MAX);
|
||
|
|
}
|
||
|
|
|
||
|
|
__attribute__((always_inline))
|
||
|
|
static inline void* hakx_tiny_alloc(size_t size) {
|
||
|
|
return hak_tiny_alloc(size);
|
||
|
|
}
|
||
|
|
|
||
|
|
__attribute__((always_inline))
|
||
|
|
static inline int hakx_tiny_maybe_free(void* ptr) {
|
||
|
|
if (!ptr) return 1;
|
||
|
|
if (hak_tiny_owner_slab(ptr) || hak_super_lookup(ptr)) {
|
||
|
|
hak_tiny_free(ptr);
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|