From d1b90717328bb21d13c7ec47c19ccab26c3dfb0e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 9 May 2006 12:48:20 +0000 Subject: [PATCH] make plot work right in 3m svn: r2876 --- collects/plot/fit-low-level.ss | 2 +- collects/plot/plplot.ss | 21 +++++++++++++++++---- collects/plot/pre-installer.ss | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/collects/plot/fit-low-level.ss b/collects/plot/fit-low-level.ss index 8fec6e4156..c27c53ede3 100644 --- a/collects/plot/fit-low-level.ss +++ b/collects/plot/fit-low-level.ss @@ -4,7 +4,7 @@ (define libfit (ffi-lib (build-path (this-expression-source-directory) - "compiled" "native" (system-library-subpath) + "compiled" "native" (system-library-subpath #f) "libfit"))) (define do-fit-int diff --git a/collects/plot/plplot.ss b/collects/plot/plplot.ss index 20f32ff323..b31158b779 100644 --- a/collects/plot/plplot.ss +++ b/collects/plot/plplot.ss @@ -6,13 +6,26 @@ (define libplplot (ffi-lib (build-path (this-expression-source-directory) - "compiled" "native" (system-library-subpath) "libplplot"))) + "compiled" "native" (system-library-subpath #f) "libplplot"))) (define plplotlibdir (get-ffi-obj "plplotLibDir" libplplot _string)) -;; set the lib dir to contain the fonts. -(set-ffi-obj! "plplotLibDir" libplplot _string - (path->string (this-expression-source-directory))) +;; set the lib dir to contain the fonts: +(let ([path (this-expression-source-directory)]) + ;; free current pointer, if any: + (let ([p (get-ffi-obj "plplotLibDir" libplplot _pointer)]) + (when p (free p))) + ;; install new value: + (set-ffi-obj! "plplotLibDir" libplplot _bytes + ;; malloc the string, since the GC won't see the static variable: + (let* ([gced-bytes (path->bytes path)] + [len (bytes-length gced-bytes)] + [p (malloc (add1 len) 'raw)] + [malloced-bytes (make-sized-byte-string p len)]) + (bytes-copy! malloced-bytes 0 gced-bytes) + ;; set nul terminator: + (ptr-set! p _byte len 0) + malloced-bytes))) (define _plflt _double*) (define _plint _int) diff --git a/collects/plot/pre-installer.ss b/collects/plot/pre-installer.ss index dd1b628e5c..436cb14b45 100644 --- a/collects/plot/pre-installer.ss +++ b/collects/plot/pre-installer.ss @@ -9,7 +9,7 @@ (define tmp-dir (build-path src-dir "tmp")) (define dir->libname '(["all" "libplplot"] ["fit" "libfit"])) (define native-dir - (build-path top-dir "compiled" "native" (system-library-subpath))) + (build-path top-dir "compiled" "native" (system-library-subpath #f))) (define (build-library lib) (when (and (directory-exists? lib)