Skip to content

Instantly share code, notes, and snippets.

@shriphani
Last active December 20, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shriphani/6127911 to your computer and use it in GitHub Desktop.
Save shriphani/6127911 to your computer and use it in GitHub Desktop.
Racket mmap
(define-cstruct _mmap_obj ([fd _int]
[loaded_size _uint32]
[content _pointer]))
(define-cstruct _wp_index ([pathname_base _pointer]
[num_segments _uint16]
[sizeof_segments _uint16]
[docid_offsets _pointer]
[segments _pointer]
[open _uint8]
[indexinfo _mmap_obj]))
(define-whistlepig wp_index_create (_fun [m : (_ptr o (_ptr o _wp_index))] _string -> [n : _pointer] -> (if (not n) m n)))
(define (add-source-files)
(define source-files (filter
(lambda (f) (string-index f (string->char-set ".rkt")))
(map path->string (directory-list))))
(map
(lambda (file-path)
(begin
(define index (wp_index_create "index"))
(define entry (wp_entry_new))
(define f (fopen file-path "r"))
(wp_entry_add_file entry "body" f)
(wp_index_add_entry index entry)
(wp_entry_free entry)
(fclose f)
(printf "Added source files in CWD to the index\n")))
source-files))
Error:
racket(25776,0x7fff78e64180) malloc: *** mmap(size=9223372036854775808) failed (error code=12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment