[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [PATCH 3/4] libgst: Some trivial fixes
From: |
Lee Duhem |
Subject: |
[Help-smalltalk] [PATCH 3/4] libgst: Some trivial fixes |
Date: |
Wed, 26 Apr 2017 19:19:31 +0800 |
2017-04-26 Lee Duhem <address@hidden>
* callin.c (_gst_type_name_to_oop): Replace sprintf with snprintf.
(_gst_class_name_to_oop): Clean properly before return.
* cint.c (_gst_invoke_croutine): Clean properly before return.
* dict.c (create_metaclass): Synchronize prototype with definition.
(init_smalltalk_dictionary): Replace sprintf with snprintf.
* oop.c (_gst_alloc_obj): Reduce size properly.
* oop.h (INITIAL_OOP_TABLE_SIZE): Sychronize with comment.
(_gst_grow_memory_to): Synchronize prototype with definition.
---
libgst/ChangeLog | 11 +++++++++++
libgst/callin.c | 7 +++++--
libgst/cint.c | 5 ++++-
libgst/dict.c | 8 ++++----
libgst/oop.c | 2 +-
libgst/oop.h | 4 ++--
6 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index e876657..4d1375c 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,5 +1,16 @@
2017-04-26 Lee Duhem <address@hidden>
+ * callin.c (_gst_type_name_to_oop): Replace sprintf with snprintf.
+ (_gst_class_name_to_oop): Clean properly before return.
+ * cint.c (_gst_invoke_croutine): Clean properly before return.
+ * dict.c (create_metaclass): Synchronize prototype with definition.
+ (init_smalltalk_dictionary): Replace sprintf with snprintf.
+ * oop.c (_gst_alloc_obj): Reduce size properly.
+ * oop.h (INITIAL_OOP_TABLE_SIZE): Sychronize with comment.
+ (_gst_grow_memory_to): Synchronize prototype with definition.
+
+2017-04-26 Lee Duhem <address@hidden>
+
* cint.c: Include ffi.h properly.
* dict.c (create_classes_pass1): Use INCR_INT.
(init_c_symbols): Replace magic number with corresponding macro.
diff --git a/libgst/callin.c b/libgst/callin.c
index dd30511..369e0be 100644
--- a/libgst/callin.c
+++ b/libgst/callin.c
@@ -386,7 +386,7 @@ _gst_type_name_to_oop (const char *name)
OOP result;
char buf[300];
- sprintf (buf, "^%s!", name);
+ snprintf (buf, sizeof (buf), "^%s!", name);
result = _gst_eval_expr (buf);
return (result);
@@ -469,7 +469,10 @@ _gst_class_name_to_oop (const char *name)
key = _gst_intern_string (prev_p);
result = dictionary_at (result, key);
if (IS_NIL (result))
- return NULL;
+ {
+ free (s);
+ return NULL;
+ }
}
free (s);
diff --git a/libgst/cint.c b/libgst/cint.c
index 6848234..a9585e8 100644
--- a/libgst/cint.c
+++ b/libgst/cint.c
@@ -837,7 +837,10 @@ _gst_invoke_croutine (OOP cFuncOOP,
funcAddr = cobject_value (cFuncOOP);
if (!funcAddr)
- return (NULL);
+ {
+ INC_RESTORE_POINTER (incPtr);
+ return (NULL);
+ }
p_slot = pointer_map_insert (cif_cache, cFuncOOP);
if (!*p_slot)
diff --git a/libgst/dict.c b/libgst/dict.c
index 9acb44c..6e11fc6 100644
--- a/libgst/dict.c
+++ b/libgst/dict.c
@@ -231,8 +231,8 @@ static void create_class (const class_definition *ci);
NUMMETACLASSSUBCLASSES in the instance variable "subclasses" of the
metaclass. */
static void create_metaclass (OOP class_oop,
- int numSubClasses,
- int numMetaclassSubClasses);
+ int numMetaclassSubClasses,
+ int numSubClasses);
/* Finish initializing the metaclass METACLASSOOP. */
static void init_metaclass (OOP metaclassOOP);
@@ -1030,8 +1030,8 @@ init_smalltalk_dictionary (void)
for (i = 0; i < numFeatures; i++)
featuresArray->data[i] = _gst_intern_string (feature_strings[i]);
- sprintf (fullVersionString, "GNU Smalltalk version %s",
- VERSION PACKAGE_GIT_REVISION);
+ snprintf (fullVersionString, sizeof (fullVersionString),
+ "GNU Smalltalk version %s", VERSION PACKAGE_GIT_REVISION);
add_smalltalk ("Smalltalk", _gst_smalltalk_dictionary);
add_smalltalk ("Version", _gst_string_new (fullVersionString));
diff --git a/libgst/oop.c b/libgst/oop.c
index 71e837a..ed2b949 100644
--- a/libgst/oop.c
+++ b/libgst/oop.c
@@ -787,7 +787,7 @@ _gst_alloc_obj (size_t size,
if UNCOMMON (newAllocPtr >= _gst_mem.eden.maxPtr)
{
_gst_scavenge ();
- newAllocPtr = _gst_mem.eden.allocPtr + size;
+ newAllocPtr = _gst_mem.eden.allocPtr + BYTES_TO_SIZE (size);
}
p_instance = (gst_object) _gst_mem.eden.allocPtr;
diff --git a/libgst/oop.h b/libgst/oop.h
index efc51da..acc488d 100644
--- a/libgst/oop.h
+++ b/libgst/oop.h
@@ -75,7 +75,7 @@
/* The number of OOPs in the system. This is exclusive of Character,
True, False, and UndefinedObject (nil) oops, which are
built-ins. */
-#define INITIAL_OOP_TABLE_SIZE (1024 * 128 + BUILTIN_OBJECT_BASE)
+#define INITIAL_OOP_TABLE_SIZE (1024 * 128 + FIRST_OOP_INDEX)
#define MAX_OOP_TABLE_SIZE (1 << 23)
/* The number of free OOPs under which we trigger GCs. 0 is not
@@ -413,7 +413,7 @@ extern gst_object _gst_alloc_words (size_t size)
/* Grows the allocated memory to SPACESIZE bytes, if it's not there
already. */
-extern void _gst_grow_memory_to (size_t size)
+extern void _gst_grow_memory_to (size_t spaceSize)
ATTRIBUTE_HIDDEN;
/* Grow the OOP table to NEWSIZE pointers and initialize the newly
--
2.9.3