Backup
This commit is contained in:
parent
be327a3ec9
commit
85fde94124
|
|
@ -0,0 +1,23 @@
|
||||||
|
(define-record-type <arena>
|
||||||
|
(internal-make-arena pointer size fixed?)
|
||||||
|
arena?
|
||||||
|
(pointer arena-pointer)
|
||||||
|
(size arena-size)
|
||||||
|
(fixed? arena-fixed?))
|
||||||
|
|
||||||
|
(define make-arena
|
||||||
|
(lambda options
|
||||||
|
#t
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (call-with-arena arena thunk)
|
||||||
|
#t
|
||||||
|
)
|
||||||
|
|
||||||
|
(define (arena-allocate arena size)
|
||||||
|
#t
|
||||||
|
)
|
||||||
|
|
||||||
|
(define (free-arena arena)
|
||||||
|
#t
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
(define-library
|
||||||
|
(retropikzel arena)
|
||||||
|
(import (scheme base)
|
||||||
|
(scheme write)
|
||||||
|
(foreign c))
|
||||||
|
(export make-arena
|
||||||
|
arena?
|
||||||
|
call-with-arena
|
||||||
|
arena-allocate
|
||||||
|
free-arena)
|
||||||
|
(include "arena.scm"))
|
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
## Arenas
|
||||||
|
|
||||||
|
Arena is static or growing size of memory which can be use to allocate
|
||||||
|
c-bytevectors and then free them all at once. All memory allocated in arenas
|
||||||
|
is zeroed by default.
|
||||||
|
|
||||||
|
(**make-arena** [options])
|
||||||
|
|
||||||
|
Creates and returns a new arena. Options is list of pairs.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
- (size . N)
|
||||||
|
- If the size argument is given, that much memory is allocated up front.
|
||||||
|
- (fixed? . #t/#f)
|
||||||
|
- #f means the arena grows automatically on allocation, #t means it does not
|
||||||
|
and any allocation that would go over arena size will throw an error.
|
||||||
|
- If #t and size is not given error will thrown
|
||||||
|
|
||||||
|
(**arena?** obj)
|
||||||
|
|
||||||
|
Returns #t if obj is arena, #f otherwise.
|
||||||
|
|
||||||
|
(**call-with-arena** arena thunk)
|
||||||
|
|
||||||
|
Call thunk with given arena as first argument. After the thunk returns arena
|
||||||
|
is freed. If the thunk does not return, for example error occurs, the arena is
|
||||||
|
not freed.
|
||||||
|
|
||||||
|
|
||||||
|
(**arena-allocate** arena size)
|
||||||
|
|
||||||
|
Allocate c-bytevector of given size from the given arena and return it. If
|
||||||
|
allocation fails, error is signaled.
|
||||||
|
|
||||||
|
|
||||||
|
(**free-arena** arena)
|
||||||
|
|
||||||
|
Free the whole arena.
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
(define-library
|
||||||
|
(retropikzel stdio)
|
||||||
|
(import (scheme base)
|
||||||
|
(scheme write)
|
||||||
|
(foreign c))
|
||||||
|
(export fopen
|
||||||
|
;fclose
|
||||||
|
;feof
|
||||||
|
;ferror
|
||||||
|
;fgetc
|
||||||
|
;fgets
|
||||||
|
;fprintf
|
||||||
|
;fputc
|
||||||
|
;fputs
|
||||||
|
;fread
|
||||||
|
;fscanf
|
||||||
|
;fseek
|
||||||
|
;ftell
|
||||||
|
;fwrite
|
||||||
|
;getc
|
||||||
|
;getchar
|
||||||
|
;printf
|
||||||
|
;putc
|
||||||
|
;putchar
|
||||||
|
;puts
|
||||||
|
;remove
|
||||||
|
;rename
|
||||||
|
;rewind
|
||||||
|
;scanf
|
||||||
|
;snprintf
|
||||||
|
;sprintf
|
||||||
|
;sscanf
|
||||||
|
)
|
||||||
|
(include "stiod.scm"))
|
||||||
|
|
||||||
Loading…
Reference in New Issue