mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
add scm_c_make_port; the port table is now a weak set
* libguile/ports.c (scm_c_make_port_with_encoding, scm_c_make_port): New functions, to replace scm_new_port_table_entry. Use a weak set instead of a weak table. (scm_i_remove_port): (scm_c_port_for_each, scm_port_for_each): Adapt to use weak set. (scm_i_void_port): Use scm_c_make_port. (scm_init_ports): Make a weak set. * libguile/fports.c: * libguile/ioext.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/vports.c: Adapt to use the new scm_c_make_port API.
This commit is contained in:
parent
7887be7df5
commit
2721f9182d
7 changed files with 140 additions and 208 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2006 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2006, 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
|
@ -269,7 +269,7 @@ SCM_DEFINE (scm_primitive_move_to_fdes, "primitive-move->fdes", 2, 0, 0,
|
|||
#undef FUNC_NAME
|
||||
|
||||
static SCM
|
||||
get_matching_port (void *closure, SCM port, SCM val, SCM result)
|
||||
get_matching_port (void *closure, SCM port, SCM result)
|
||||
{
|
||||
int fd = * (int *) closure;
|
||||
scm_t_port *entry = SCM_PTAB_ENTRY (port);
|
||||
|
@ -292,11 +292,9 @@ SCM_DEFINE (scm_fdes_to_ports, "fdes->ports", 1, 0, 0,
|
|||
SCM result = SCM_EOL;
|
||||
int int_fd = scm_to_int (fd);
|
||||
|
||||
scm_i_scm_pthread_mutex_lock (&scm_i_port_table_mutex);
|
||||
result = scm_internal_hash_fold (get_matching_port,
|
||||
(void*) &int_fd, result,
|
||||
scm_i_port_weak_hash);
|
||||
scm_i_pthread_mutex_unlock (&scm_i_port_table_mutex);
|
||||
result = scm_c_weak_set_fold (get_matching_port,
|
||||
(void*) &int_fd, result,
|
||||
scm_i_port_weak_set);
|
||||
return result;
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue