From a122163218967a05f9cf66d3d9e6f032b8ea0286 Mon Sep 17 00:00:00 2001 From: Scott Olsen Date: Thu, 21 Apr 2022 21:28:40 -0400 Subject: [PATCH] refactor: make fread more general fread can technically accept any object -- it takes a void pointer. Our current implementation assumes the object is a String, which limits the applicability of this function. This change alters the definition to accept any type. --- core/IO.carp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/IO.carp b/core/IO.carp index dab0ced55..056697504 100644 --- a/core/IO.carp +++ b/core/IO.carp @@ -47,7 +47,7 @@ module are wrappers around the C standard library.") (register fread- (Fn [a Int Int (Ptr FILE)] Int) "fread") (doc fread "reads from a file into C-String (thin wrapper for fread(cstr, item-size, items-count, file) from C standard library). Consider using [`read-file`](#read-file) or [`unsafe-read-file`](#unsafe-read-file) instead.") (defn fread [file-name item-size items-count file] - (fread- (String.cstr file-name) item-size items-count file) ) + (fread- file-name item-size items-count file) ) (doc fflush "flushes a file pointer, i.e. commits every write (thin wrapper for the C standard library).") (register fflush (Fn [(Ptr FILE)] Int) "fflush") (doc fflush! "same as (fflush) but to be used as a side effect.")