[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
guile/guile-core/libguile ChangeLog fports.c po...
From: |
Gary Houston |
Subject: |
guile/guile-core/libguile ChangeLog fports.c po... |
Date: |
Sat, 17 Mar 2001 08:59:49 -0800 |
CVSROOT: /cvs
Module name: guile
Changes by: Gary Houston <address@hidden> 01/03/17 08:59:48
Modified files:
guile-core/libguile: ChangeLog fports.c ports.c gc.c
Log message:
* gc.c (scm_must_malloc): changed the comment explaining when
scm_must variants of malloc/free etc., should be used, based on
explanation from Dirk Herrmann.
* fports.c (scm_fport_buffer_add): use FUNC_NAME instead of a local
string with procedure name. use scm_must_malloc instead of malloc.
(scm_setvbuf, scm_fdes_to_port, fport_close): use scm_must variants
of malloc/free.
* ports.c (scm_add_to_port_table, scm_remove_from_port_table,
scm_ungetc): use scm_must variants of malloc/realloc/free.
(scm_add_to_port_table, scm_ungetc): define FUNC_NAME.
CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ChangeLog.diff?r1=1.1328&r2=1.1329
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/fports.c.diff?r1=1.91&r2=1.92
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ports.c.diff?r1=1.137&r2=1.138
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/gc.c.diff?r1=1.185&r2=1.186
Patches:
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1328
guile/guile-core/libguile/ChangeLog:1.1329
--- guile/guile-core/libguile/ChangeLog:1.1328 Sat Mar 17 05:34:21 2001
+++ guile/guile-core/libguile/ChangeLog Sat Mar 17 08:59:48 2001
@@ -1,3 +1,16 @@
+2001-03-17 Gary Houston <address@hidden>
+
+ * gc.c (scm_must_malloc): changed the comment explaining when
+ scm_must variants of malloc/free etc., should be used, based on
+ explanation from Dirk Herrmann.
+ * fports.c (scm_fport_buffer_add): use FUNC_NAME instead of a local
+ string with procedure name. use scm_must_malloc instead of malloc.
+ (scm_setvbuf, scm_fdes_to_port, fport_close): use scm_must variants
+ of malloc/free.
+ * ports.c (scm_add_to_port_table, scm_remove_from_port_table,
+ scm_ungetc): use scm_must variants of malloc/realloc/free.
+ (scm_add_to_port_table, scm_ungetc): define FUNC_NAME.
+
2001-03-17 Dirk Herrmann <address@hidden>
* __scm.h (SCM_ASSERT, SCM_WTA_DISPATCH_0, SCM_WTA_DISPATCH_1,
Index: guile/guile-core/libguile/fports.c
diff -u guile/guile-core/libguile/fports.c:1.91
guile/guile-core/libguile/fports.c:1.92
--- guile/guile-core/libguile/fports.c:1.91 Fri Feb 23 12:24:14 2001
+++ guile/guile-core/libguile/fports.c Sat Mar 17 08:59:48 2001
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999, 2000 Free Software Foundation,
Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software
Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -80,10 +80,10 @@
0 for no buffer. */
static void
scm_fport_buffer_add (SCM port, int read_size, int write_size)
+#define FUNC_NAME "scm_fport_buffer_add"
{
struct scm_fport *fp = SCM_FSTREAM (port);
scm_port *pt = SCM_PTAB_ENTRY (port);
- char *s_scm_fport_buffer_add = "scm_fport_buffer_add";
if (read_size == -1 || write_size == -1)
{
@@ -104,9 +104,7 @@
if (SCM_INPUT_PORT_P (port) && read_size > 0)
{
- pt->read_buf = malloc (read_size);
- if (pt->read_buf == NULL)
- scm_memory_error (s_scm_fport_buffer_add);
+ pt->read_buf = scm_must_malloc (read_size, FUNC_NAME);
pt->read_pos = pt->read_end = pt->read_buf;
pt->read_buf_size = read_size;
}
@@ -118,9 +116,7 @@
if (SCM_OUTPUT_PORT_P (port) && write_size > 0)
{
- pt->write_buf = malloc (write_size);
- if (pt->write_buf == NULL)
- scm_memory_error (s_scm_fport_buffer_add);
+ pt->write_buf = scm_must_malloc (write_size, FUNC_NAME);
pt->write_pos = pt->write_buf;
pt->write_buf_size = write_size;
}
@@ -136,6 +132,7 @@
else
SCM_SET_CELL_WORD_0 (port, SCM_CELL_WORD_0 (port) | SCM_BUF0);
}
+#undef FUNC_NAME
SCM_DEFINE (scm_setvbuf, "setvbuf", 2, 1, 0,
(SCM port, SCM mode, SCM size),
@@ -189,9 +186,9 @@
/* silently discards buffered chars. */
if (pt->read_buf != &pt->shortbuf)
- free (pt->read_buf);
+ scm_must_free (pt->read_buf);
if (pt->write_buf != &pt->shortbuf)
- free (pt->write_buf);
+ scm_must_free (pt->write_buf);
scm_fport_buffer_add (port, csize, csize);
return SCM_UNSPECIFIED;
@@ -386,9 +383,9 @@
{
struct scm_fport *fp
- = (struct scm_fport *) malloc (sizeof (struct scm_fport));
- if (fp == NULL)
- SCM_MEMORY_ERROR;
+ = (struct scm_fport *) scm_must_malloc (sizeof (struct scm_fport),
+ FUNC_NAME);
+
fp->fdes = fdes;
pt->rw_random = SCM_FDES_RANDOM_P (fdes);
SCM_SETSTREAM (port, fp);
@@ -768,10 +765,10 @@
if (pt->read_buf == pt->putback_buf)
pt->read_buf = pt->saved_read_buf;
if (pt->read_buf != &pt->shortbuf)
- free (pt->read_buf);
+ scm_must_free (pt->read_buf);
if (pt->write_buf != &pt->shortbuf)
- free (pt->write_buf);
- free ((char *) fp);
+ scm_must_free (pt->write_buf);
+ scm_must_free ((char *) fp);
return rv;
}
Index: guile/guile-core/libguile/gc.c
diff -u guile/guile-core/libguile/gc.c:1.185
guile/guile-core/libguile/gc.c:1.186
--- guile/guile-core/libguile/gc.c:1.185 Fri Mar 16 02:00:17 2001
+++ guile/guile-core/libguile/gc.c Sat Mar 17 08:59:48 2001
@@ -1839,10 +1839,11 @@
* scm_must_malloc, scm_must_realloc, scm_must_free, scm_done_malloc,
* scm_done_free
*
- * These functions provide services comperable to malloc, realloc, and
- * free. They are for allocating malloced parts of scheme objects.
- * The primary purpose of the front end is to impose calls to gc. */
-
+ * These functions provide services comparable to malloc, realloc, and
+ * free. They should be used when allocating memory that will be under
+ * control of the garbage collector, i.e., if the memory may be freed
+ * during garbage collection.
+ */
/* scm_must_malloc
* Return newly malloced storage or throw an error.
Index: guile/guile-core/libguile/ports.c
diff -u guile/guile-core/libguile/ports.c:1.137
guile/guile-core/libguile/ports.c:1.138
--- guile/guile-core/libguile/ports.c:1.137 Fri Mar 16 02:00:17 2001
+++ guile/guile-core/libguile/ports.c Sat Mar 17 08:59:48 2001
@@ -431,11 +431,14 @@
scm_port *
scm_add_to_port_table (SCM port)
+#define FUNC_NAME "scm_add_to_port_table"
{
scm_port *entry;
if (scm_port_table_size == scm_port_table_room)
{
+ /* initial malloc is in gc.c. this doesn't use scm_must_malloc etc.,
+ since it can never be freed during gc. */
void *newt = realloc ((char *) scm_port_table,
(scm_sizet) (sizeof (scm_port *)
* scm_port_table_room * 2));
@@ -444,9 +447,7 @@
scm_port_table = (scm_port **) newt;
scm_port_table_room *= 2;
}
- entry = (scm_port *) malloc (sizeof (scm_port));
- if (entry == NULL)
- scm_memory_error ("scm_add_to_port_table");
+ entry = (scm_port *) scm_must_malloc (sizeof (scm_port), FUNC_NAME);
entry->port = port;
entry->entry = scm_port_table_size;
@@ -465,6 +466,7 @@
return entry;
}
+#undef FUNC_NAME
/* Remove a port from the table and destroy it. */
@@ -478,8 +480,8 @@
if (i >= scm_port_table_size)
SCM_MISC_ERROR ("Port not in table: ~S", SCM_LIST1 (port));
if (p->putback_buf)
- free (p->putback_buf);
- free (p);
+ scm_must_free (p->putback_buf);
+ scm_must_free (p);
/* Since we have just freed slot i we can shrink the table by moving
the last entry to that slot... */
if (i < scm_port_table_size - 1)
@@ -1101,6 +1103,7 @@
void
scm_ungetc (int c, SCM port)
+#define FUNC_NAME "scm_ungetc"
{
scm_port *pt = SCM_PTAB_ENTRY (port);
@@ -1112,11 +1115,10 @@
&& pt->read_buf == pt->read_pos)
{
int new_size = pt->read_buf_size * 2;
- unsigned char *tmp =
- (unsigned char *) realloc (pt->putback_buf, new_size);
+ unsigned char *tmp = (unsigned char *)
+ scm_must_realloc (pt->putback_buf, pt->read_buf_size, new_size,
+ FUNC_NAME);
- if (tmp == NULL)
- scm_memory_error ("scm_ungetc");
pt->read_pos = pt->read_buf = pt->putback_buf = tmp;
pt->read_end = pt->read_buf + pt->read_buf_size;
pt->read_buf_size = pt->putback_buf_size = new_size;
@@ -1141,9 +1143,8 @@
if (pt->putback_buf == NULL)
{
pt->putback_buf
- = (unsigned char *) malloc (SCM_INITIAL_PUTBACK_BUF_SIZE);
- if (pt->putback_buf == NULL)
- scm_memory_error ("scm_ungetc");
+ = (unsigned char *) scm_must_malloc (SCM_INITIAL_PUTBACK_BUF_SIZE,
+ FUNC_NAME);
pt->putback_buf_size = SCM_INITIAL_PUTBACK_BUF_SIZE;
}
@@ -1172,6 +1173,7 @@
else
SCM_COL(port) -= 1;
}
+#undef FUNC_NAME
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- guile/guile-core/libguile ChangeLog fports.c po...,
Gary Houston <=