1Simple C GC 2=========== 3 4This is the readme file for Simple C GC. Simple C GC is a simple 5garbage collection system for the C programming language inspired by 6[Daniel Holden's article about Cello's garbage collection 7system](http://libcello.org/learn/garbage-collection). 8 9Usage 10----- 11 12The interface of Simple C GC consists of only two functions: 13 14```C 15/** 16 * This function starts code that will be garbage collected 17 * 18 * @param main The function that will be started and garbage collected 19 * @param argc Passed to main 20 * @param argv Passed to main 21 * @param my_malloc Simple C GC will use this to allocated memory 22 * @param my_free Simple C GC will use this to free memory 23 */ 24int scgc_start_gced_code(int (*main)(int, char *[]), 25 int argc, 26 char *argv[], 27 void* (*my_malloc)( size_t ), 28 void (*my_free)( void* )); 29 30/** 31 * Allocate a new memory block that will be garbage collected 32 * 33 * @param size The size of the new memory block 34 */ 35void* scgc_new(size_t size); 36``` 37 38An example that illustrates how these functions can be used in 39practice is located in the `test.c` file. 40 41 42Notes 43----- 44 45The garbage collector assumes that all data that should be garbage 46collected is pointed to directly or indirectly from the "C stack" and 47that the "C stack" is implemented as a continuous block of memory. 48 49Compile and Test 50---------------- 51 52 make test 53 54License 55------- 56 57 Copyright 2019 Kjell Winblad (kjellwinblad@gmail.com, http://winsh.me) 58 59 Licensed under the Apache License, Version 2.0 (the "License"); 60 you may not use this file except in compliance with the License. 61 You may obtain a copy of the License at 62 63 http://www.apache.org/licenses/LICENSE-2.0 64 65 Unless required by applicable law or agreed to in writing, software 66 distributed under the License is distributed on an "AS IS" BASIS, 67 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 68 See the License for the specific language governing permissions and 69 limitations under the License.