LispBM
Loading...
Searching...
No Matches
lbm_defrag_mem.h
Go to the documentation of this file.
1/*
2 Copyright 2024, 2025 Joel Svensson svenssonjoel@yahoo.se
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef LBM_DEFRAG_MEM_H_
19#define LBM_DEFRAG_MEM_H_
20
21#include <heap.h>
22#include <stdint.h>
23
25extern void lbm_defrag_mem_destroy(lbm_uint *ptr);
26extern lbm_value lbm_defrag_mem_alloc(lbm_uint *defrag_mem, lbm_uint nbytes);
27//extern lbm_value lbm_defrag_mem_alloc_lisparray(lbm_uint *defrag_mem, lbm_uint elts);
28extern void lbm_defrag_mem_free(lbm_uint* data);
29
30static inline bool lbm_defrag_mem_valid(lbm_value arr) {
31 return !(lbm_is_symbol_nil(lbm_car(arr)));
32}
33
34static inline bool lbm_is_defrag_mem(lbm_value x) {
35 lbm_type t = lbm_type_of(x);
36 return ((t == LBM_TYPE_DEFRAG_MEM) && lbm_defrag_mem_valid(x)) ;
37}
38
39
40#endif
static bool lbm_is_symbol_nil(lbm_value exp)
Definition heap.h:858
static lbm_type lbm_type_of(lbm_value x)
Definition heap.h:682
lbm_value lbm_car(lbm_value cons)
Definition heap.c:997
#define LBM_TYPE_DEFRAG_MEM
Definition lbm_defines.h:58
lbm_value lbm_defrag_mem_alloc(lbm_uint *defrag_mem, lbm_uint nbytes)
Definition lbm_defrag_mem.c:225
lbm_value lbm_defrag_mem_create(lbm_uint nbytes)
Definition lbm_defrag_mem.c:42
static bool lbm_is_defrag_mem(lbm_value x)
Definition lbm_defrag_mem.h:34
void lbm_defrag_mem_free(lbm_uint *data)
Definition lbm_defrag_mem.c:268
static bool lbm_defrag_mem_valid(lbm_value arr)
Definition lbm_defrag_mem.h:30
void lbm_defrag_mem_destroy(lbm_uint *ptr)
Definition lbm_defrag_mem.c:88
uint32_t lbm_uint
Definition lbm_types.h:48
uint32_t lbm_type
Definition lbm_types.h:46
uint32_t lbm_value
Definition lbm_types.h:44