1 /* 2 * %CopyrightBegin% 3 * 4 * Copyright 2019 Kjell Winblad (kjellwinblad@gmail.com, http://winsh.me). 5 * All Rights Reserved. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * 19 * %CopyrightEnd% 20 */ 21 22 /** 23 * Pulic interface for Simple C GC. 24 * 25 * @author Kjell Winblad 26 * 27 */ 28 29 #ifndef SIMPLE_C_GC_H 30 #define SIMPLE_C_GC_H 31 32 #include <stddef.h> 33 34 /** 35 * This function starts code that will be garbage collected 36 * 37 * @param main The function that will be started and garbage collected 38 * @param argc Passed to main 39 * @param argv Passed to main 40 * @param my_malloc Simple C GC will use this to allocated memory 41 * @param my_free Simple C GC will use this to free memory 42 */ 43 int scgc_start_gced_code(int (*main)(int, char *[]), int argc, char *argv[], 44 void *(*my_malloc)(size_t), void (*my_free)(void *)); 45 46 /** 47 * Allocate a new memory block that will be garbage collected 48 * 49 * @param size The size of the new memory block 50 */ 51 void *scgc_new(size_t size); 52 53 /** 54 * Enables printing of garbage collection information 55 */ 56 void scgc_enable_print_gc_info(void); 57 #endif 58