summaryrefslogtreecommitdiff
path: root/libguile/ports.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-04-03 11:39:21 +0200
committerAndy Wingo <wingo@pobox.com>2016-04-04 16:30:56 +0200
commit67b147fb7a5e8771b0314fcc0fcc826db09d9949 (patch)
tree16fb15deb0f53abbd4dfc8e511a4443aba775a66 /libguile/ports.h
parent4460f1f15280e3378633115fe9035448a68c636b (diff)
downloadguile-67b147fb7a5e8771b0314fcc0fcc826db09d9949.tar.gz
Remove port free functions; just close instead
* libguile/ports.h (scm_t_port_type_flags): Replace SCM_PORT_TYPE_HAS_FLUSH with SCM_PORT_TYPE_NEEDS_CLOSE_ON_GC. (scm_t_ptob_descriptor): Remove free function. * libguile/ports.c (scm_set_port_needs_close_on_gc): New function. (scm_set_port_flush): Don't set flags. (scm_c_make_port_with_encoding, scm_close_port): Use the new flag to determine when to add a finalizer and also when to include the port in the weak set. (scm_set_port_free): Remove. (do_close, finalize_port): Close port instead of calling free function. * libguile/r6rs-ports.c (initialize_transcoded_ports): * libguile/vports.c (scm_make_sfptob): * libguile/fports.c (scm_make_fptob): Mark these ports as needing close on GC. * libguile/fports.c (fport_free): Remove. * NEWS: Update. * doc/ref/api-io.texi (Port Implementation): Update.
Diffstat (limited to 'libguile/ports.h')
-rw-r--r--libguile/ports.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/libguile/ports.h b/libguile/ports.h
index f6c217fe3..379fba294 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -177,14 +177,15 @@ SCM_INTERNAL SCM scm_i_port_weak_set;
typedef enum scm_t_port_type_flags {
- SCM_PORT_TYPE_HAS_FLUSH = 1 << 0
+ /* Indicates that the port should be closed if it is garbage collected
+ while it is open. */
+ SCM_PORT_TYPE_NEEDS_CLOSE_ON_GC = 1 << 0
} scm_t_port_type_flags;
/* port-type description. */
typedef struct scm_t_ptob_descriptor
{
char *name;
- size_t (*free) (SCM);
int (*print) (SCM exp, SCM port, scm_print_state *pstate);
SCM (*equalp) (SCM, SCM);
int (*close) (SCM port);
@@ -223,13 +224,13 @@ SCM_API scm_t_bits scm_make_port_type (char *name,
void (*write) (SCM port,
const void *data,
size_t size));
-SCM_API void scm_set_port_free (scm_t_bits tc, size_t (*free) (SCM));
SCM_API void scm_set_port_print (scm_t_bits tc,
int (*print) (SCM exp,
SCM port,
scm_print_state *pstate));
SCM_API void scm_set_port_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM));
SCM_API void scm_set_port_close (scm_t_bits tc, int (*close) (SCM));
+SCM_API void scm_set_port_needs_close_on_gc (scm_t_bits tc, int needs_close_p);
SCM_API void scm_set_port_flush (scm_t_bits tc, void (*flush) (SCM port));
SCM_API void scm_set_port_end_input (scm_t_bits tc,