diff --git a/lib/chibi/io.module b/lib/chibi/io.module index c7b95743..14c95429 100644 --- a/lib/chibi/io.module +++ b/lib/chibi/io.module @@ -8,6 +8,6 @@ make-null-output-port make-broadcast-port make-concatenated-port make-generated-input-port make-filtered-output-port make-filtered-input-port) - (import-immutable (scheme)) + (import-immutable (scheme) (chibi ast)) (include-shared "io/io") (include "io/io.scm")) diff --git a/tools/chibi-ffi b/tools/chibi-ffi index 688640b1..01daa084 100755 --- a/tools/chibi-ffi +++ b/tools/chibi-ffi @@ -703,7 +703,7 @@ ((and (not (type-result? a)) (type-array a) (not (string-type? a))) (if (not (number? (type-array a))) (cat " tmp" (type-index a) - " = (" (type-c-name (type-base a)) "*) malloc(" + " = (" (type-c-name (type-base a)) "*) calloc(1, " "(sexp_unbox_fixnum(sexp_length(ctx, arg" (type-index a) "))+1) * sizeof(tmp" (type-index a) "[0]));\n")) (cat " for (i=0, res=arg" (type-index a) @@ -720,7 +720,7 @@ (not (type-auto-expand? a)) (or (not (type-array a)) (not (integer? len)))) - (cat " tmp" (type-index a) " = malloc(" + (cat " tmp" (type-index a) " = calloc(1, " (if (and (symbol? len) (not (eq? len 'null))) (lambda () (cat (lambda () (scheme->c-converter 'unsigned-int len)) "*sizeof(tmp" (type-index a) "[0])")) @@ -848,7 +848,7 @@ " free(tmp" i ");\n")) (cat " len" i " *= 2;\n" " tmp" i - " = malloc(len" i "*sizeof(tmp" i "[0]));\n" + " = calloc(1, len" i "*sizeof(tmp" i "[0]));\n" " goto loop;\n"))))) (else " res = SEXP_FALSE;\n")) @@ -1087,7 +1087,7 @@ " res = sexp_alloc_tagged(ctx, sexp_sizeof(cpointer), sexp_type_tag(" (type-id-name name) "));\n" - " r = sexp_cpointer_value(res) = malloc(sizeof(" + " r = sexp_cpointer_value(res) = calloc(1, sizeof(" (or (type-struct-type name) "") " " (type-name name) "));\n" " sexp_freep(res) = 1;\n" (lambda () @@ -1161,7 +1161,7 @@ *funcs*) (cat "static char* sexp_concat_env_string (sexp x) {\n" " int klen=sexp_string_length(sexp_car(x)), vlen=sexp_string_length(sexp_cdr(x));\n" - " char *res = (char*) malloc(klen+vlen+2);\n" + " char *res = (char*) calloc(1, klen+vlen+2);\n" " strncpy(res, sexp_string_data(sexp_car(x)), klen);\n" " res[sexp_string_length(sexp_car(x))] = '=';\n" " strncpy(res+sexp_string_length(sexp_car(x)), sexp_string_data(sexp_cdr(x)), vlen);\n"