diff options
author | Andy Wingo <wingo@pobox.com> | 2015-01-22 13:04:11 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2015-01-22 13:04:11 +0100 |
commit | d5dffec4ffcb93ab649acb2b6f7d8a013ba0e10e (patch) | |
tree | 7dd1a075652e87bc446c44d17bb2f7ef1ced0062 /libguile/load.c | |
parent | e2fafeb9012cbe5e3ec63326692a4cc3a22c318e (diff) | |
parent | a7bbba05838cabe2294f498e7008e1c51db6d664 (diff) | |
download | guile-d5dffec4ffcb93ab649acb2b6f7d8a013ba0e10e.tar.gz |
Merge commit 'a7bbba05838cabe2294f498e7008e1c51db6d664'
Diffstat (limited to 'libguile/load.c')
-rw-r--r-- | libguile/load.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libguile/load.c b/libguile/load.c index a68d96d7d..b6e07a549 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -402,24 +402,24 @@ SCM scm_listofnullstr; /* Utility functions for assembling C strings in a buffer. */ -struct stringbuf { +struct stringbuf +{ char *buf, *ptr; size_t buf_len; }; static void -stringbuf_free (void *data) -{ - struct stringbuf *buf = (struct stringbuf *)data; - free (buf->buf); -} - -static void stringbuf_grow (struct stringbuf *buf) { - size_t ptroff = buf->ptr - buf->buf; - buf->buf_len *= 2; - buf->buf = scm_realloc (buf->buf, buf->buf_len); + size_t ptroff, prev_len; + void *prev_buf = buf->buf; + + prev_len = buf->buf_len; + ptroff = buf->ptr - buf->buf; + + buf->buf_len *= 2; + buf->buf = scm_gc_malloc_pointerless (buf->buf_len, "search-path"); + memcpy (buf->buf, prev_buf, prev_len); buf->ptr = buf->buf + ptroff; } @@ -557,6 +557,7 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts, char *filename_chars; size_t filename_len; SCM result = SCM_BOOL_F; + char initial_buffer[256]; if (scm_ilength (path) < 0) scm_misc_error ("%search-path", "path is not a proper list: ~a", @@ -618,9 +619,8 @@ search_path (SCM path, SCM filename, SCM extensions, SCM require_exts, if (scm_is_null (extensions)) extensions = scm_listofnullstr; - buf.buf_len = 512; - buf.buf = scm_malloc (buf.buf_len); - scm_dynwind_unwind_handler (stringbuf_free, &buf, SCM_F_WIND_EXPLICITLY); + buf.buf_len = sizeof initial_buffer; + buf.buf = initial_buffer; /* Try every path element. */ |