[uim-commit] r2518 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Sat Dec 10 00:52:55 PST 2005
Author: yamaken
Date: 2005-12-10 00:52:34 -0800 (Sat, 10 Dec 2005)
New Revision: 2518
Modified:
branches/r5rs/sigscheme/debug.c
branches/r5rs/sigscheme/eval.c
branches/r5rs/sigscheme/io.c
branches/r5rs/sigscheme/operations-nonstd.c
branches/r5rs/sigscheme/operations.c
branches/r5rs/sigscheme/sigschemeinternal.h
branches/r5rs/sigscheme/storage-gc.c
branches/r5rs/sigscheme/storage-symbol.c
Log:
* sigscheme/sigschemeinternal.h
- (LBUF_ALLOC, LBUF_REALLOC): Replace ?alloc() with Scm_?alloc() and
remove manual error handling
* sigscheme/storage-gc.c
- (malloc_aligned):
* Replace malloc() with Scm_malloc()
* Add error handling for posix_memalign()
- (SigScm_GC_Protect, add_heap): Replace ?alloc() with Scm_?alloc()
and remove manual error handling
* sigscheme/storage-symbol.c
- (initialize_symbol_hash): Replace malloc() with Scm_malloc() and
remove manual error handling
* sigscheme/debug.c
- (hash_grow, SigScm_WriteToPortWithSharedStructure): Replace
malloc(), realloc() and calloc() with Scm_?alloc()
* sigscheme/io.c
- (find_path, parse_script_prelude, parse_script_prelude): Ditto
* sigscheme/operations.c
- (ScmOp_string_setd, ScmOp_substring, ScmOp_string_append,
ScmOp_string_filld, ScmOp_make_vector, ScmOp_list2vector): Ditto
* sigscheme/operations-nonstd.c
- (create_loaded_str): Ditto
* sigscheme/eval.c
- (qquote_vector): Ditto
Modified: branches/r5rs/sigscheme/debug.c
===================================================================
--- branches/r5rs/sigscheme/debug.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/debug.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -549,7 +549,7 @@
new_size = old_size * 2;
old_ents = tab->ents;
- tab->ents = calloc(new_size, sizeof(hash_entry));
+ tab->ents = Scm_calloc(new_size, sizeof(hash_entry));
tab->size = new_size;
tab->used = 0;
@@ -694,7 +694,7 @@
ctx.next_index = 1;
ctx.seen.size = 1 << 8; /* arbitrary initial size */
- ctx.seen.ents = calloc(ctx.seen.size, sizeof(hash_entry));
+ ctx.seen.ents = Scm_calloc(ctx.seen.size, sizeof(hash_entry));
for (i = 0; i < ctx.seen.size; i++) {
ctx.seen.ents[i].key = SCM_INVALID;
}
Modified: branches/r5rs/sigscheme/eval.c
===================================================================
--- branches/r5rs/sigscheme/eval.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/eval.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -1314,7 +1314,7 @@
return my_result;
}
- copy_buf = malloc((len + growth) * sizeof(ScmObj));
+ copy_buf = Scm_malloc((len + growth) * sizeof(ScmObj));
/* i indexes input and cpi indexes copy_buf. */
next_rindex = SCM_INT_VALUE(CAAR(replacements));
Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/io.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -529,7 +529,7 @@
filename_len = strlen(filename);
path_len = lib_path_len + sizeof((char)'/') + filename_len + sizeof((char)'\0');
- path = malloc(path_len);
+ path = Scm_malloc(path_len);
snprintf(path, path_len, "%s/%s", scm_lib_path, filename);
if (file_existsp(path))
return path;
@@ -609,7 +609,7 @@
}
#endif
- argv = malloc(sizeof(char *));
+ argv = Scm_malloc(sizeof(char *));
argc = 0;
for (p = &line[3]; p < &line[SCRIPT_PRELUDE_MAXLEN]; p += len + 1) {
p += strspn(p, SCRIPT_PRELUDE_DELIM);
@@ -618,7 +618,7 @@
p[len] = '\0';
arg = strdup(p);
argv[argc] = arg;
- argv = realloc(argv, sizeof(char *) * (++argc + 1));
+ argv = Scm_realloc(argv, sizeof(char *) * (++argc + 1));
argv[argc] = NULL;
}
}
Modified: branches/r5rs/sigscheme/operations-nonstd.c
===================================================================
--- branches/r5rs/sigscheme/operations-nonstd.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/operations-nonstd.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -135,7 +135,7 @@
/* generate loaded_str, contents is filename-loaded* */
size = (strlen(SCM_STRING_STR(filename)) + strlen("*-loaded*") + 1);
- loaded_str = (char*)malloc(sizeof(char) * size);
+ loaded_str = Scm_malloc(size);
snprintf(loaded_str, size, "*%s-loaded*", SCM_STRING_STR(filename));
return Scm_NewImmutableString(loaded_str);
Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/operations.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -1244,7 +1244,7 @@
total_size = prefix_size + newch_size + postfix_size;
/* copy each part */
- new_str = (char*)malloc(total_size + 1);
+ new_str = Scm_malloc(total_size + 1);
memcpy(new_str, string_str, prefix_size);
memcpy(new_str+prefix_size, new_ch_str, newch_size);
memcpy(new_str+prefix_size+newch_size,
@@ -1304,7 +1304,7 @@
mbs = Scm_mb_substring(mbs, c_start_index, c_end_index - c_start_index);
/* copy from start_ptr to end_ptr */
- new_str = (char*)malloc(SCM_MBS_GET_SIZE(mbs) + 1);
+ new_str = Scm_malloc(SCM_MBS_GET_SIZE(mbs) + 1);
memcpy(new_str, SCM_MBS_GET_STR(mbs), SCM_MBS_GET_SIZE(mbs));
new_str[SCM_MBS_GET_SIZE(mbs)] = 0;
@@ -1334,8 +1334,7 @@
total_len += SCM_STRING_LEN(obj);
}
- /* allocate new string */
- new_str = (char*)malloc(sizeof(char) * total_size + 1);
+ new_str = Scm_malloc(total_size + 1);
/* copy string by string */
p = new_str;
@@ -1442,7 +1441,7 @@
/* create new str */
char_size = next - ch_str;
- new_str = realloc(SCM_STRING_STR(str), str_len * char_size + 1);
+ new_str = Scm_realloc(SCM_STRING_STR(str), str_len * char_size + 1);
for (p = new_str; p < &new_str[char_size * str_len]; p += char_size) {
strcpy(p, ch_str);
}
@@ -1477,7 +1476,7 @@
/* allocate vector */
len = SCM_INT_VALUE(vector_len);
- vec = (ScmObj*)malloc(sizeof(ScmObj) * len);
+ vec = Scm_malloc(sizeof(ScmObj) * len);
/* fill vector */
filler = SCM_UNDEF;
@@ -1494,7 +1493,7 @@
{
int len = SCM_INT_VALUE(ScmOp_length(args));
int i = 0;
- ScmObj *vec = (ScmObj*)malloc(sizeof(ScmObj) * len); /* allocate vector */
+ ScmObj *vec = Scm_malloc(sizeof(ScmObj) * len); /* allocate vector */
DECLARE_FUNCTION("vector", ProcedureVariadic0);
/* set item */
@@ -1577,7 +1576,7 @@
scm_len = ScmOp_length(lst);
c_len = SCM_INT_VALUE(scm_len);
- v = (ScmObj*)malloc(sizeof(ScmObj) * c_len);
+ v = Scm_malloc(sizeof(ScmObj) * c_len);
for (i = 0; i < c_len; i++) {
v[i] = CAR(lst);
lst = CDR(lst);
Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/sigschemeinternal.h 2005-12-10 08:52:34 UTC (rev 2518)
@@ -377,25 +377,16 @@
#define LBUF_ALLOC(lbuf, size) \
do { \
- (lbuf)._buf = malloc(size); \
+ (lbuf)._buf = Scm_malloc(size); \
(lbuf)._size = (size); \
- if (!(lbuf)._buf) \
- ERR("memory exhausted"); \
} while (/* CONSTCOND */ 0)
#define LBUF_REALLOC(lbuf, size) \
do { \
if ((lbuf)._buf == (lbuf)._init_buf) { \
- void *new_buf; \
- \
- new_buf = malloc(size); \
- if (!new_buf) \
- ERR("memory exhausted"); \
- (lbuf)._buf = memcpy(new_buf, LBUF_BUF(lbuf), LBUF_SIZE(lbuf)); \
+ (lbuf)._buf = memcpy(Scm_malloc(size), LBUF_BUF(lbuf), LBUF_SIZE(lbuf)); \
} else { \
- (lbuf)._buf = realloc((lbuf)._buf, (size)); \
- if (!(lbuf)._buf) \
- ERR("memory exhausted"); \
+ (lbuf)._buf = Scm_realloc((lbuf)._buf, (size)); \
} \
(lbuf)._size = (size); \
} while (/* CONSTCOND */ 0)
Modified: branches/r5rs/sigscheme/storage-gc.c
===================================================================
--- branches/r5rs/sigscheme/storage-gc.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/storage-gc.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -202,15 +202,14 @@
void SigScm_GC_Protect(ScmObj *var)
{
ScmObj **slot;
+ size_t new_size;
if (n_empty_protected_vars) {
slot = locate_protected_var(NULL);
n_empty_protected_vars--;
} else {
- protected_vars = realloc(protected_vars,
- sizeof(ScmObj *) * (protected_vars_size + 1));
- if (!protected_vars)
- ERR("memory exhausted"); /* FIXME: replace with fatal error */
+ new_size = sizeof(ScmObj *) * (protected_vars_size + 1);
+ protected_vars = Scm_realloc(protected_vars, new_size);
slot = &protected_vars[protected_vars_size++];
}
*slot = var;
@@ -283,8 +282,10 @@
* BSD 4.4. The function posix_memalign() comes from POSIX 1003.1d.
*/
posix_memalign(&p, 16, size);
+ if (!p)
+ ERR("memory exhausted");
#else
- p = malloc(size);
+ p = Scm_malloc(size);
/* heaps must be aligned to sizeof(ScmCell) */
assert(!((uintptr_t)p % sizeof(ScmCell)));
#endif
@@ -320,10 +321,8 @@
if (n_heaps_max <= n_heaps)
Scm_FatalError("heap exhausted");
- heaps = realloc(heaps, sizeof(ScmObjHeap) * (n_heaps + 1));
+ heaps = Scm_realloc(heaps, sizeof(ScmObjHeap) * (n_heaps + 1));
heap = malloc_aligned(sizeof(ScmCell) * heap_size);
- if (!heaps || !heap)
- ERR("memory exhausted"); /* FIXME: replace with fatal error handling */
heaps[n_heaps++] = heap;
/* update the enclosure */
Modified: branches/r5rs/sigscheme/storage-symbol.c
===================================================================
--- branches/r5rs/sigscheme/storage-symbol.c 2005-12-10 08:22:41 UTC (rev 2517)
+++ branches/r5rs/sigscheme/storage-symbol.c 2005-12-10 08:52:34 UTC (rev 2518)
@@ -122,9 +122,7 @@
{
int i;
- scm_symbol_hash = malloc(sizeof(ScmObj) * NAMEHASH_SIZE);
- if (!scm_symbol_hash)
- ERR("memory exhausted");
+ scm_symbol_hash = Scm_malloc(sizeof(ScmObj) * NAMEHASH_SIZE);
for (i = 0; i < NAMEHASH_SIZE; i++)
scm_symbol_hash[i] = SCM_NULL;
More information about the uim-commit
mailing list