[Scummvm-cvs-logs] SF.net SVN: scummvm:[38360] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Feb 16 10:40:26 CET 2009


Revision: 38360
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38360&view=rev
Author:   fingolfin
Date:     2009-02-16 09:40:25 +0000 (Mon, 16 Feb 2009)

Log Message:
-----------
SCI: Committed stuff I forgot in my last commit; changed int_hash_map_t to a C++ class

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/int_hashmap.cpp
    scummvm/trunk/engines/sci/engine/int_hashmap.h
    scummvm/trunk/engines/sci/engine/savegame.cfsml
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/include/vm.h
    scummvm/trunk/engines/sci/module.mk

Removed Paths:
-------------
    scummvm/trunk/engines/sci/include/hashmap.h
    scummvm/trunk/engines/sci/include/int_hashmap.h
    scummvm/trunk/engines/sci/include/seg_manager.h
    scummvm/trunk/engines/sci/scicore/hashmap.cpp
    scummvm/trunk/engines/sci/scicore/int_hashmap.cpp

Modified: scummvm/trunk/engines/sci/engine/int_hashmap.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/int_hashmap.cpp	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/engine/int_hashmap.cpp	2009-02-16 09:40:25 UTC (rev 38360)
@@ -29,82 +29,38 @@
 
 
 #define HASH_MAX DCS_INT_HASH_MAX
-#define COMP(x, y) ((x)-(y))
 #define HASH(x) (x & 0xff)
 
-int_hash_map_t *
-new_int_hash_map(void) {
-	int_hash_map_t *map = (int_hash_map_t*)calloc(1, sizeof(int_hash_map_t));
-
-	return map;
+int_hash_map_t::int_hash_map_t() {
+	base_value = 0;
+	memset(nodes, 0, sizeof(nodes));
+	holes = 0;
 }
 
-
-static void
-print_int_nodes(int_hash_map_node_t *node) {
-	while (node) {
-		fprintf(stderr, "%p  ", (void *)node);
-		node = node->next;
-	}
-}
-
-void
-print_int_hash_map(int_hash_map_t *map) {
-	int bucket;
-	fprintf(stderr, "int map %p: base value=%d\n", (void *)map,
-	        map->base_value);
-	for (bucket = 0; bucket <= HASH_MAX; bucket++) {
-		fprintf(stderr, "bucket %d: ", bucket);
-		print_int_nodes(map->nodes[bucket]);
-		fprintf(stderr, "\n");
-	}
-	fprintf(stderr, "holes: ");
-	print_int_nodes(map->holes);
-	fprintf(stderr, "\n");
-}
-
-void
-apply_to_int_hash_map(int_hash_map_t *map, void *param, void (*note)(void *param, int name, int value)) {
-	int i;
-	for (i = 0; i < HASH_MAX; i++) {
-		int_hash_map_node_t *node = map->nodes[i];
-		while (node) {
-			note(param, node->name, node->value);
-			node = node->next;
-		}
-	}
-}
-
-
-static void
-free_int_hash_map_node_t_recursive(int_hash_map_node_t *node) {
+void int_hash_map_t::free_node_recursive(node_t *node) {
 	if (node) {
-		free_int_hash_map_node_t_recursive(node->next);
+		free_node_recursive(node->next);
 		free(node);
 	}
 }
 
 
-void
-free_int_hash_map(int_hash_map_t *map) {
+int_hash_map_t::~int_hash_map_t() {
 	int i;
 
 	for (i = 0; i <= HASH_MAX; i++)
-		free_int_hash_map_node_t_recursive(map->nodes[i]);
+		free_node_recursive(nodes[i]);
 
-	free_int_hash_map_node_t_recursive(map->holes);
+	free_node_recursive(holes);
 
-	map->base_value = -42000; /* Trigger problems for people who
-			     ** forget to loose the reference  */
-	free(map);
+	// Trigger problems for people who forget to loose the reference
+	base_value = -42000;
 }
 
-int
-int_hash_map_check_value(int_hash_map_t *map, int value,
-                         char add, char *was_added) {
-	int_hash_map_node_t **node = &(map->nodes[HASH(value)]);
+int int_hash_map_t::check_value(int value, bool add, char *was_added) {
+	node_t **node = &(nodes[HASH(value)]);
 
-	while (*node && COMP(value, (*node)->name))
+	while (*node && (value != (*node)->name))
 		node = &((*node)->next);
 
 	if (was_added)
@@ -121,15 +77,15 @@
 	if (was_added)
 		*was_added = 1;
 
-	if (map->holes) { /* Re-use old node */
-		(*node) = map->holes;
-		map->holes = (*node)->next;
+	if (holes) { /* Re-use old node */
+		(*node) = holes;
+		holes = (*node)->next;
 		(*node)->next = NULL;
 		(*node)->name = value;
 	} else {
-		*node = (int_hash_map_node_t*)malloc(sizeof(int_hash_map_node_t));
+		*node = (node_t*)malloc(sizeof(node_t));
 		(*node)->name = value;
-		(*node)->value = map->base_value++;
+		(*node)->value = base_value++;
 		(*node)->next = NULL;
 	}
 
@@ -137,20 +93,20 @@
 }
 
 
-int
-int_hash_map_remove_value(int_hash_map_t *map, int value) {
-	int_hash_map_node_t **node = &(map->nodes[HASH(value)]);
+int int_hash_map_t::remove_value(int value) {
+	node_t **node = &(nodes[HASH(value)]);
 
-	while (*node && COMP(value, (*node)->name))
+	while (*node && (value != (*node)->name))
 		node = &((*node)->next);
 
 	if (*node) {
-		int_hash_map_node_t *oldnode = *node;
+		node_t *oldnode = *node;
 		*node = (*node)->next;
 
-		oldnode->next = map->holes; /* Old node is now a 'hole' */
-		map->holes = oldnode;
+		oldnode->next = holes; /* Old node is now a 'hole' */
+		holes = oldnode;
 		return oldnode->value;
-	} else return -1; /* Not found */
+	} else
+		return -1; /* Not found */
 }
 

Modified: scummvm/trunk/engines/sci/engine/int_hashmap.h
===================================================================
--- scummvm/trunk/engines/sci/engine/int_hashmap.h	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/engine/int_hashmap.h	2009-02-16 09:40:25 UTC (rev 38360)
@@ -44,67 +44,45 @@
 #define DCS_INT_HASH_MAX 255
 
 
-struct int_hash_map_node_t {
-	int name;
-	int value;
-	int_hash_map_node_t *next;
-};
-
-
 struct int_hash_map_t {
+	struct node_t {
+		int name;
+		int value;
+		node_t *next;
+	};
+
 	int base_value;  /* Starts at zero, counts upwards */
-	int_hash_map_node_t *nodes[DCS_INT_HASH_MAX+1];
-	int_hash_map_node_t *holes; /* List of freed entries to minimize
+	node_t *nodes[DCS_INT_HASH_MAX+1];
+	node_t *holes; /* List of freed entries to minimize
 				     ** memory operations and modifications
 				     ** to base_value  */
-};
 
-typedef int_hash_map_t *int_hash_map_ptr;
+	void free_node_recursive(node_t *node);
 
+public:
+	int_hash_map_t();
+	~int_hash_map_t();
+	
+	/**
+	 * Checks whether a value is in the map, adds it if neccessary.
+	 * @param value		The value to check for/add
+	 * @param add		Whether to add the value if it's not in there
+	 * @param was_added	Set to non-zero iff the value is new, ignored if NULL.
+	 * @return The new (or old) index, or -1 if add was zero and
+	 *                   the value couldn't be found
+	 */
+	int check_value(int value, bool add, char *was_added = 0);
 
-int_hash_map_t *
-new_int_hash_map(void);
-/* Creates a new hash map for the specified int
-** Parameters: (void)
-** Returns   : (int_hash_map_t *) The newly allocated hash map
-*/
+	/**
+	 * Removes a value from the hash map.
+	 * @param value		The value to remove
+	 * @return	The ID of the value, or -1 if it wasn't present
+	 */
+	int remove_value(int value);
 
-void
-free_int_hash_map(int_hash_map_ptr map);
-/* Frees the specified hash map
-** Parameters: (int_hash_map_t *) map: The map to free
-** Returns   : (void)
-*/
+};
 
-void
-apply_to_int_hash_map(int_hash_map_ptr map, void *param, void (*note)(void *param, int name, int value));
-/* Iterates over all entries in the hash map and invokes 'note'
-** Parameters: (int_hash_map_t *) map: The map to iterate over
-**             (void *) param: Some parameter to pass to 'note'
-**             ((voidptr * int * value) -> void) note: The callback to invoke for each entry
-*/
+typedef int_hash_map_t *int_hash_map_ptr;
 
-int
-int_hash_map_check_value(int_hash_map_ptr map, int value, char add, char *was_added);
-/* Checks whether a value is in the map, adds it if neccessary
-** Parameters: (int_hash_map_t *) map: The map to look in/modify
-**             (int) value: The value to check for/add
-**             (char) add: Whether to add the value if it's not in there
-**             (char *) was_added: Set to non-zero iff the value is new
-**                                 Ignored if NULL.
-** Returns   : (int) The new (or old) index, or -1 if add was zero and
-**                   the value couldn't be found
-** If MUST_FREE is defined and add is set but the value was already in
-** there, the value is freed.
-*/
 
-int
-int_hash_map_remove_value(int_hash_map_ptr map, int value);
-/* Removes a value from the hash map
-** Parameters: (int_hash_map_t *) map: The map to remove from
-**             (int) value: The value to remove
-** Returns   : (int) The ID of the value, or -1 if it wasn't presen
-*/
-
-
 #endif /* INT_HASHMAP_H */

Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-02-16 09:40:25 UTC (rev 38360)
@@ -163,9 +163,9 @@
 read_songlib_t(FILE *fh, songlib_t *foo, const char *lastval, int *line, int *hiteof);
 
 void
-write_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo);
+write_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo);
 int
-read_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo, const char *lastval, int *line, int *hiteof);
+read_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo, const char *lastval, int *line, int *hiteof);
 
 int
 read_song_tp(FILE *fh, song_t **foo, const char *lastval, int *line, int *hiteof);
@@ -185,7 +185,7 @@
 TYPE reg_t "reg_t" USING write_reg_t read_reg_t;
 TYPE size_t "size_t" LIKE int;
 TYPE int_hash_map_tp "int_hash_map_t *" USING write_int_hash_map_tp read_int_hash_map_tp;
-TYPE int_hash_map_node_tp "int_hash_map_node_t *" USING write_int_hash_map_node_tp read_int_hash_map_node_tp;
+TYPE int_hash_map_node_tp "int_hash_map_t::node_t *" USING write_int_hash_map_node_tp read_int_hash_map_node_tp;
 TYPE songlib_t "songlib_t" USING write_songlib_t read_songlib_t;
 TYPE song_tp "song_t *" USING write_song_tp read_song_tp;
 TYPE song_iterator_t "song_iterator_t" USING write_song_iterator_t read_song_iterator_t;
@@ -490,7 +490,7 @@
 }
 
 void
-write_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo) {
+write_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo) {
 	if (!(*foo)) {
 		fputs("\\null", fh);
 	} else {
@@ -503,13 +503,13 @@
 }
 
 int
-read_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo, const char *lastval, int *line, int *hiteof) {
+read_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo, const char *lastval, int *line, int *hiteof) {
 	static char buffer[80];
 
 	if (lastval[0] == '\\') {
 		*foo = NULL; /* No hash map node */
 	} else {
-		*foo = (int_hash_map_node_t*)malloc(sizeof(int_hash_map_node_t));
+		*foo = (int_hash_map_t::node_t*)malloc(sizeof(int_hash_map_t::node_t));
 		if (lastval[0] != '[') {
 			sciprintf("Expected opening bracket in hash_map_node_t on line %d\n", *line);
 			return 1;

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-02-16 09:40:25 UTC (rev 38360)
@@ -163,9 +163,9 @@
 read_songlib_t(FILE *fh, songlib_t *foo, const char *lastval, int *line, int *hiteof);
 
 void
-write_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo);
+write_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo);
 int
-read_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo, const char *lastval, int *line, int *hiteof);
+read_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo, const char *lastval, int *line, int *hiteof);
 
 int
 read_song_tp(FILE *fh, song_t **foo, const char *lastval, int *line, int *hiteof);
@@ -4207,7 +4207,7 @@
 	int i;
 
 	for (i = 0; i <= MEM_OBJ_MAX; i++) {
-		if (!scumm_stricmp(mem_obj_string_names[i].name, str))
+		if (!strcasecmp(mem_obj_string_names[i].name, str))
 			return i;
 	}
 
@@ -4302,7 +4302,7 @@
 }
 
 void
-write_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo) {
+write_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo) {
 	if (!(*foo)) {
 		fputs("\\null", fh);
 	} else {
@@ -4320,13 +4320,13 @@
 }
 
 int
-read_int_hash_map_node_tp(FILE *fh, int_hash_map_node_t **foo, const char *lastval, int *line, int *hiteof) {
+read_int_hash_map_node_tp(FILE *fh, int_hash_map_t::node_t **foo, const char *lastval, int *line, int *hiteof) {
 	static char buffer[80];
 
 	if (lastval[0] == '\\') {
 		*foo = NULL; /* No hash map node */
 	} else {
-		*foo = (int_hash_map_node_t*)malloc(sizeof(int_hash_map_node_t));
+		*foo = (int_hash_map_t::node_t*)malloc(sizeof(int_hash_map_t::node_t));
 		if (lastval[0] != '[') {
 			sciprintf("Expected opening bracket in hash_map_node_t on line %d\n", *line);
 			return 1;

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-02-16 09:40:25 UTC (rev 38360)
@@ -94,8 +94,7 @@
 	int retval = 0;
 
 	while (!was_added) {
-		retval = int_hash_map_check_value(self->id_seg_map, self->reserved_id,
-		                                  1, &was_added);
+		retval = self->id_seg_map->check_value(self->reserved_id, true, &was_added);
 		*id = self->reserved_id--;
 		if (self->reserved_id < -1000000)
 			self->reserved_id = -10;
@@ -118,9 +117,9 @@
 
 	self->mem_allocated = 0; /* Initialise memory count */
 
-	self->id_seg_map = new_int_hash_map();
+	self->id_seg_map = new int_hash_map_t();
 	self->reserved_id = INVALID_SCRIPT_ID;
-	int_hash_map_check_value(self->id_seg_map, self->reserved_id, 1, NULL);	/* reserve 0 for seg_id */
+	self->id_seg_map->check_value(self->reserved_id, true);	/* reserve 0 for seg_id */
 	self->reserved_id--;	/* reserved_id runs in the reversed direction to make sure no one will use it. */
 
 	self->heap_size = DEFAULT_SCRIPTS;
@@ -152,7 +151,7 @@
 			_sm_deallocate(self, i, 0);
 	}
 
-	free_int_hash_map(self->id_seg_map);
+	delete self->id_seg_map;
 
 	sci_free(self->heap);
 	self->heap = NULL;
@@ -170,7 +169,7 @@
 	char was_added;
 	mem_obj_t* mem;
 
-	seg = int_hash_map_check_value(self->id_seg_map, script_nr, 1, &was_added);
+	seg = self->id_seg_map->check_value(script_nr, true, &was_added);
 	if (!was_added) {
 		*seg_id = seg;
 		return self->heap[*seg_id];
@@ -256,7 +255,7 @@
 	scr->marked_as_deleted = 0;
 	scr->relocated = 0;
 
-	scr->obj_indices = new_int_hash_map();
+	scr->obj_indices = new int_hash_map_t();
 
 	if (s->version >= SCI_VERSION(1, 001, 000))
 		scr->heap_start = scr->buf + scr->script_size;
@@ -272,7 +271,7 @@
 	VERIFY(sm_check(self, seg), "invalid seg id");
 
 	mobj = self->heap[seg];
-	int_hash_map_remove_value(self->id_seg_map, mobj->segmgr_id);
+	self->id_seg_map->remove_value(mobj->segmgr_id);
 
 	switch (mobj->type) {
 
@@ -452,7 +451,7 @@
 		mem->data.script.objects_nr = 0;
 	}
 
-	free_int_hash_map(mem->data.script.obj_indices);
+	delete mem->data.script.obj_indices;
 	if (NULL != mem->data.script.code) {
 		sci_free(mem->data.script.code);
 	}
@@ -597,7 +596,7 @@
 
 /* return the seg if script_id is valid and in the map, else -1 */
 int sm_seg_get(seg_manager_t* self, int script_id) {
-	return int_hash_map_check_value(self->id_seg_map, script_id, 0, NULL);
+	return self->id_seg_map->check_value(script_id, false);
 }
 
 /* validate the seg
@@ -966,7 +965,7 @@
 	}
 
 	temp = make_reg(obj_pos.segment, base);
-	id = int_hash_map_check_value(scr->obj_indices, base, 1, NULL);
+	id = scr->obj_indices->check_value(base, true);
 	scr->objects_nr++;
 
 	obj = scr->objects + id;
@@ -1041,7 +1040,7 @@
 
 	}
 
-	id = int_hash_map_check_value(scr->obj_indices, obj_pos.offset, 1, NULL);
+	id = scr->obj_indices->check_value(obj_pos.offset, true);
 	scr->objects_nr++;
 
 	obj = scr->objects + id;

Deleted: scummvm/trunk/engines/sci/include/hashmap.h
===================================================================
--- scummvm/trunk/engines/sci/include/hashmap.h	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/include/hashmap.h	2009-02-16 09:40:25 UTC (rev 38360)
@@ -1,132 +0,0 @@
-/***************************************************************************
- hashmap.h Copyright (C) 2001 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
-    Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-/* Defines a hash map that maps values to small integers.
-** Preprocessor parameters:
-** TYPE: The type to hash
-** HASH_MAX: Maximum hash value
-** HASH(x): Hashes a value of type TYPE to an int from 0 to HASH_MAX
-** COMP(x, y): Compares x, y, returns zero(!) iff they are equal
-** MUST_FREE: Define if 'lost' values are simple pointers and should be freed
-** DUPLICATOR: Usually needed when MUST_FREE is being used, means that
-**             new values must be dup'd before being added.
-**             Define it to the name of the function to use for duplication
-**             (e.g. '#define DUPLICATOR strdup').
-*/
-
-/**-- WARNING!!! --**/
-
-/* This file uses a lot of dark magic (aka preprocessor macros) to define
-** its semantics. It is not to be taken lightly. It is not to be taken
-** as an example for good programming. Most importantly, it is not to
-** be read by mere mortals, except for the author and other people who
-** have undergone appropriate psychological preparation. Keep out of
-** reach of small children. Do not shake. Do not put in a microwave. Do
-** not feed to animals.
-*/
-
-/* OK, it's not that bad. */
-
-
-#ifndef HASH_MAX
-#  error "Must define the maximum hash value (HASH_MAX) before including hashmap.h!"
-#endif
-
-#ifndef HASH
-#  error "Must define the hash function (HASH) before including hashmap.h!"
-#endif
-
-#ifndef COMP
-#  error "Must define a comparison function (COMP) before including hashmap.h!"
-#endif
-
-
-#define DECLARE_STRUCTS(TYPE) \
-typedef struct _##TYPE##_hash_map_node {                                    \
-	TYPE name;                                                          \
-	int value;                                                          \
-	struct _##TYPE##_hash_map_node *next;                               \
-} TYPE##_hash_map_node_t;                                                   \
-                                                                            \
-                                                                            \
-typedef struct {                                                            \
-	int base_value;  /* Starts at zero, counts upwards */               \
-	TYPE##_hash_map_node_t *nodes[HASH_MAX+1];                          \
-	TYPE##_hash_map_node_t *holes; /* List of freed entries to minimize \
-				     ** memory operations and modifications \
-				     ** to base_value  */                   \
-} TYPE##_hash_map_t, *TYPE##_hash_map_ptr;
-
-
-#define DECLARE_FUNCTIONS(TYPE) \
-                                                                            \
-TYPE##_hash_map_t *                                                         \
-new_##TYPE##_hash_map(void);                                                \
-/* Creates a new hash map for the specified TYPE                            \
-** Parameters: (void)                                                       \
-** Returns   : (TYPE##_hash_map_t *) The newly allocated hash map           \
-*/                                                                          \
-                                                                            \
-void                                                                        \
-free_##TYPE##_hash_map(TYPE##_hash_map_ptr map);                            \
-/* Frees the specified hash map                                             \
-** Parameters: (TYPE##_hash_map_t *) map: The map to free                   \
-** Returns   : (void)                                                       \
-*/                                                                          \
-														    \
-void														    \
-apply_to_##TYPE##_hash_map(TYPE##_hash_map_ptr map, void *param, void (*note) (void *param, TYPE name, int value)); \
-/* Iterates over all entries in the hash map and invokes 'note'							    \
-** Parameters: (TYPE##_hash_map_t *) map: The map to iterate over						    \
-**             (void *) param: Some parameter to pass to 'note'							    \
-**             ((voidptr * TYPE * value) -> void) note: The callback to invoke for each entry			    \
-*/                                                                            					    \
-                                                                            \
-int                                                                         \
-TYPE##_hash_map_check_value(TYPE##_hash_map_ptr map, TYPE value, char add, char *was_added);  \
-/* Checks whether a value is in the map, adds it if neccessary              \
-** Parameters: (TYPE##_hash_map_t *) map: The map to look in/modify         \
-**             (TYPE) value: The value to check for/add                     \
-**             (char) add: Whether to add the value if it's not in there    \
-**             (char *) was_added: Set to non-zero iff the value is new     \
-**                                 Ignored if NULL.                         \
-** Returns   : (int) The new (or old) index, or -1 if add was zero and      \
-**                   the value couldn't be found                            \
-** If MUST_FREE is defined and add is set but the value was already in      \
-** there, the value is freed.                                               \
-*/                                                                          \
-                                                                            \
-int                                                                         \
-TYPE##_hash_map_remove_value(TYPE##_hash_map_ptr map, TYPE value);          \
-/* Removes a value from the hash map                                        \
-** Parameters: (TYPE##_hash_map_t *) map: The map to remove from            \
-**             (TYPE) value: The value to remove                            \
-** Returns   : (int) The ID of the value, or -1 if it wasn't presen         \
-*/
-
-
-
-

Deleted: scummvm/trunk/engines/sci/include/int_hashmap.h
===================================================================
--- scummvm/trunk/engines/sci/include/int_hashmap.h	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/include/int_hashmap.h	2009-02-16 09:40:25 UTC (rev 38360)
@@ -1,65 +0,0 @@
-/***************************************************************************
- int_hashmap.h Copyright (C) 2001 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
-    Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-
-#ifndef _INT_HASHMAP_H_
-#define _INT_HASHMAP_H_
-
-#include "common/scummsys.h"
-
-/* Assumes that the ints are relatively evenly distributed */
-
-#define DCS_INT_HASH_MAX 255
-
-#define HASH_MAX DCS_INT_HASH_MAX
-#define COMP(x, y) ((x)-(y))
-#define HASH(x) (x & 0xff)
-#undef MUST_FREE
-
-#include "hashmap.h"
-DECLARE_STRUCTS(int)
-DECLARE_FUNCTIONS(int)
-
-#ifndef BUILD_MAP_FUNCTIONS
-#  undef HASH_MAX
-#  undef COMP
-#  undef HASH
-#endif
-
-/* see hashmap.h for descriptions of these functions */
-int_hash_map_ptr
-new_int_hash_map(void);
-
-void
-free_int_hash_map(int_hash_map_ptr);
-
-int
-int_hash_map_check_value(int_hash_map_ptr, int value, char add_p, char *added);
-
-int
-int_hash_map_remove_value(int_hash_map_ptr, int value);
-
-#endif /* _INT_HASHMAP_H_ */

Deleted: scummvm/trunk/engines/sci/include/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/include/seg_manager.h	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/include/seg_manager.h	2009-02-16 09:40:25 UTC (rev 38360)
@@ -1,627 +0,0 @@
-/***************************************************************************
- seg_manager.h Copyright (C) 2002 Xiaojun Chen, Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
-    Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-
-
-#ifndef _SCI_SEG_MANAGER_H
-#define _SCI_SEG_MANAGER_H
-
-#include "sci/include/int_hashmap.h"
-#include "sci/include/sys_strings.h"
-#include "sci/include/vm.h"
-
-#define DEFAULT_SCRIPTS 32
-#define DEFAULT_OBJECTS 8	    /* default # of objects per script */
-#define DEFAULT_OBJECTS_INCREMENT 4 /* Number of additional objects to
-** instantiate if we're running out of them  */
-
-/* SCRIPT_ID must be 0 */
-typedef enum {
-SCRIPT_ID,
-SEG_ID
-} id_flag;
-
-//void dbg_print( const char* msg, void *i );	/* for debug only */
-
-/* verify the the given condition is true, output the message if condition is false, and exit
-** Parameters:
-**   cond - condition to be verified
-**   msg  - the message to be printed if condition fails
-** return:
-**   none, terminate the program if fails
-*/
-#define VERIFY( cond, msg ) if (! ( cond ) ) {\
-	sciprintf( "%s, line, %d, %s\n", __FILE__, __LINE__, msg ); \
-	BREAKPOINT(); \
-	}
-
-
-#define MEM_OBJ_INVALID		0
-#define MEM_OBJ_SCRIPT		1
-#define MEM_OBJ_CLONES		2
-#define MEM_OBJ_LOCALS		3
-#define MEM_OBJ_STACK		4
-#define MEM_OBJ_SYS_STRINGS	5
-#define MEM_OBJ_LISTS		6
-#define MEM_OBJ_NODES		7
-#define MEM_OBJ_HUNK		8
-#define MEM_OBJ_DYNMEM		9
-#define MEM_OBJ_RESERVED	10
-#define MEM_OBJ_MAX		MEM_OBJ_RESERVED /* For sanity checking */
-typedef int mem_obj_enum;
-
-struct _mem_obj;
-
-#define GET_SEGMENT(mgr, index, rtype) ((index) > 0 && (mgr).heap_size > index)?		\
-		(((mgr).heap[index] && (mgr).heap[index]->type == rtype)? (mgr).heap[index]	\
-		: NULL) /* Type does not match */						\
-	: NULL /* Invalid index */
-
-#define GET_SEGMENT_ANY(mgr, index) ((index) > 0 && (mgr).heap_size > index)?			\
-		(((mgr).heap[index])? (mgr).heap[index]						\
-		: NULL) /* Type does not match */						\
-	: NULL /* Invalid index */
-
-#define GET_OBJECT_SEGMENT(mgr, index) ((index) > 0 && (mgr).heap_size > index)?		\
-		(((mgr).heap[index]								\
-                    && ((mgr).heap[index]->type == MEM_OBJ_SCRIPT				\
-		        || (mgr).heap[index]->type == MEM_OBJ_CLONES))? (mgr).heap[index]	\
-		: NULL) /* Type does not match */						\
-	: NULL /* Invalid index */
-
-
-typedef struct _seg_manager_t {
-int_hash_map_t* id_seg_map; /* id - script id; seg - index of heap */
-struct _mem_obj** heap;
-int heap_size;		/* size of the heap */
-int reserved_id;
-int exports_wide;
-int sci1_1;
-
-int gc_mark_bits; /* For standard Mark&Sweep:
-** 1 or 0, depending on what unreachable/freshly allocated
-** memory is tagged as  */
-size_t mem_allocated; /* Total amount of memory allocated */
-
-seg_id_t clones_seg_id; /* ID of the (a) clones segment */
-seg_id_t lists_seg_id; /* ID of the (a) list segment */
-seg_id_t nodes_seg_id; /* ID of the (a) node segment */
-seg_id_t hunks_seg_id; /* ID of the (a) hunk segment */
-} seg_manager_t;
-
-
-
-/*==============================================================*/
-/* Toplevel functionality					*/
-/*==============================================================*/
-void
-sm_init(seg_manager_t* self, int sci1_1);
-/* Initialize the segment manager
-*/
-
-void
-sm_destroy(seg_manager_t* self);
-/* Deallocate all memory associated with the segment manager
-*/
-
-void
-sm_gc(seg_manager_t *self, struct _state *s);
-/* Perform garbage collection
-** Parameters: (state_t *) s: The state to operate on
-** Effects   : Unreachable objects in 's' are deallocated
-*/
-
-
-
-/*==============================================================*/
-/* 1. Scripts							*/
-/*==============================================================*/
-
-
-void
-sm_free_script(mem_obj_t* mem);
-
-mem_obj_t*
-sm_allocate_script(struct _seg_manager_t* self, struct _state *s, int script_nr, int* seg_id);
-/* Allocate a script into the segment manager
-** Parameters: (int) script_nr: number of the script to load
-**	       (state_t *) s: The state containing resource manager handlers to load the
-**			      script data
-** Returns   : (int) 0 on failure, 1 on success
-**	       (int) *seg_id: The segment ID of the newly allocated segment, on success
-
-** The script must then be initialised; see section (1b.), below.
-*/
-
-int
-sm_deallocate_script(struct _seg_manager_t* self, int script_nr);
-/* Forcefully deallocate a previously allocated script
-** Parameters: (int) script_nr: number of the script to deallocate
-** Returns   : (int) 1 on success, 0 on failure
-*/
-
-int
-sm_script_is_loaded(struct _seg_manager_t* self, int id, id_flag flag);
-/* Determines whether a script has been loaded yet
-** Parameters: (int) id: number of the script or ID of the script segment to check for
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-*/
-
-guint16
-sm_validate_export_func(struct _seg_manager_t* self, int pubfunct, int seg);
-/* Validate whether the specified public function is exported by the script in the specified segment
-** Parameters:	(int) pubfunct: Index of the function to validate
-**		(int) seg: Segment ID of the script the check is to be performed for
-** Returns   :  (guint16) 0 if the public function is invalid, its offset into the script's segment
-**			  otherwise
-**/
-
-int
-sm_seg_get(seg_manager_t* self, int script_nr);
-/* Get the segment ID associated with a script number
-** Parameters: (int) script_nr: Number of the script to look up
-** Returns   : (int) The associated segment ID, or -1 if no matching segment exists
-** This function is "pure" (i.e, it doesn't modify anything).
-*/
-
-
-/**************************/
-/* script lock operations */
-/**************************/
-
-void
-sm_increment_lockers(struct _seg_manager_t* self, int id, id_flag flag);
-/* Increments the number of lockers of the script in question by one
-** Parameters: (int) id: ID of the script or script segment to modify
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-*/
-
-void
-sm_decrement_lockers(struct _seg_manager_t* self, int id, id_flag flag);
-/* Decrements the number of lockers of the script in question by one
-** Parameters: (int) id: ID of the script or script segment to modify
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-*/
-
-int
-sm_get_lockers(struct _seg_manager_t* self, int id, id_flag flag);
-/* Retrieves the number of locks held on this script
-** Parameters: (int) id: ID of the script or script segment to read from
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** Returns   : (int) The number of locks held on the previously identified script
-*/
-
-void
-sm_set_lockers(struct _seg_manager_t* self, int lockers, int id, id_flag flag);
-/* Sets the number of locks held on the specified script
-** Parameters: (int) id: ID of the script or script segment to modify
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-*/
-
-byte *
-sm_get_synonyms(struct _seg_manager_t* self, int id, id_flag flag);
-/* Retrieves a pointer to the synonyms associated with the specified script
-** Parameters: (int) id: ID of the script or script segment to read from
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** Returns   : (byte *) Pointer to the synonyms, in non-parsed format.
-** A dynamic failure is issued if the specified ID does not reference a proper script.
-*/
-
-int
-sm_get_synonyms_nr(struct _seg_manager_t* self, int id, id_flag flag);
-/* Retrieves the number of synonyms associated with the specified script
-** Parameters: (int) id: ID of the script or script segment to read from
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** Returns   : (int) The number of synonyms associated with the specified script
-** A dynamic failure is issued if the specified ID does not reference a proper script.
-*/
-
-
-/*==============================================================*/
-/* 1b. Script Initialisation					*/
-/*==============================================================*/
-
-/*******************************************/
-/* The set of functions below are intended */
-/* to be used during script instantiation, */
-/* i.e. loading and linking.		   */
-/*******************************************/
-
-void
-sm_script_initialise_locals_zero(struct _seg_manager_t *self, seg_id_t seg, int nr);
-/* Initializes a script's local variable block
-** Parameters: (seg_id_t) seg: Segment containing the script to initialize
-**             (int) nr: Number of local variables to allocate
-** All variables are initialized to zero.
-*/
-
-void
-sm_script_initialise_locals(struct _seg_manager_t *self, reg_t location);
-/* Initializes a script's local variable block according to a prototype
-** Parameters: (reg_t) location: Location to initialize from
-*/
-
-object_t *
-sm_script_obj_init(seg_manager_t *self, struct _state *s, reg_t obj_pos);
-/* Initializes an object within the segment manager
-** Parameters: (reg_t) obj_pos: Location (segment, offset) of the object
-** Returns   : (object_t *) A newly created object_t describing the object
-** obj_pos must point to the beginning of the script/class block (as opposed
-** to what the VM considers to be the object location)
-** The corresponding object_t is stored within the relevant script.
-*/
-
-void
-sm_script_add_code_block(struct _seg_manager_t* self, reg_t location);
-/* Informs the segment manager that a code block must be relocated
-** Parameters: (reg_t) location: Start of block to relocate
-*/
-
-void
-sm_set_export_width(struct _seg_manager_t* self, int flag);
-/* Tells the segment manager whether exports are wide (32-bit) or not.
-** Parameters: (int) flag: 1 if exports are wide, 0 otherwise */
-
-void
-sm_script_relocate(struct _seg_manager_t* self, reg_t block);
-/* Processes a relocation block witin a script
-** Parameters: (reg_t) obj_pos: Location (segment, offset) of the block
-** Returns   : (object_t *) Location of the relocation block
-** This function is idempotent, but it must only be called after all
-** objects have been instantiated, or a run-time error will occur.
-*/
-
-void
-sm_script_free_unused_objects(struct _seg_manager_t *self, seg_id_t segid);
-/* Deallocates all unused but allocated entries for objects
-** Parameters: (seg_id_t) segid: segment of the script to prune in this way
-** These entries are created during script instantiation; deallocating them
-** frees up some additional memory.
-*/
-
-void
-sm_set_export_table_offset(struct _seg_manager_t* self, int offset, int id, id_flag flag);
-/* Sets the script-relative offset of the exports table
-** Parameters: (int) offset: The script-relative exports table offset
-**	       (int) id: ID of the script or script segment to write to
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** A dynamic failure is issued if the specified ID does not reference a proper script.
-*/
-
-void
-sm_set_synonyms_offset(struct _seg_manager_t* self, int offset, int id, id_flag flag);
-/* Sets the script-relative offset of the synonyms associated with the specified script
-** Parameters: (int) offset: The script-relative offset of the synonyms block
-**	       (int) id: ID of the script or script segment to write to
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** A dynamic failure is issued if the specified ID does not reference a proper script.
-*/
-
-void
-sm_set_synonyms_nr(struct _seg_manager_t* self, int nr, int id, id_flag flag);
-/* Sets the number of synonyms associated with the specified script
-** Parameters: (int) nr: The number of synonyms, as to be stored within the script
-**	       (int) id: ID of the script or script segment to write to
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** A dynamic failure is issued if the specified ID does not reference a proper script.
-*/
-
-void
-sm_mark_script_deleted(seg_manager_t* self, int script_nr);
-/* Marks the script identified by its script number as deleted
-** Parameters: (int) script_nr: Script number to mark as deleted
-** This will not actually delete the script.  If references remain present on the
-** heap or the stack, the script will stay in memory in a quasi-deleted state until
-** either unreachable (resulting in its eventual deletion) or reloaded (resulting
-** in its data being updated).
-*/
-
-void
-sm_unmark_script_deleted(seg_manager_t* self, int script_nr);
-/* Marks the script identified by its script number as not deleted
-** Parameters: (int) script_nr: Script number to mark as not deleted
-*/
-
-int
-sm_script_is_marked_as_deleted(seg_manager_t* self, seg_id_t seg);
-/* Determines whether the script referenced by the indicated segment is marked as being deleted.
-** Parameters: (seg_id_t) Segment ID of the script to investigate
-** Returns   : (int) 1 iff seg points to a script and the segment is deleted, 0 otherwise
-** Will return 0 when applied to an invalid or non-script seg.
-*/
-
-
-
-/*==============================================================*/
-/* 2. Clones							*/
-/*==============================================================*/
-
-clone_t*
-sm_alloc_clone(struct _seg_manager_t *self, reg_t *addr);
-/* Allocate a fresh clone
-** Returns : (clone_t*): Reference to the memory allocated for the clone
-**           (reg_t) *addr: The offset of the freshly allocated clone
-*/
-
-void
-sm_free_clone(struct _seg_manager_t *self, reg_t addr);
-/* Deallocates a clone
-** Parameters: (reg_t) addr: Offset of the clone scheduled for termination
-*/
-
-
-
-/*==============================================================*/
-/* Objects (static, from Scripts, and dynmic, from Clones)	*/
-/*==============================================================*/
-
-/* Not all of these functions are fully operational for clones ATM */
-
-gint16
-sm_get_heap(struct _seg_manager_t* self, reg_t reg);
-/* Retrieves a 16 bit value from within a script's heap representation
-** Parameters: (reg_t) reg: The address to read from
-** Returns   : (gint16) The value read from the specified location
-*/
-
-void
-sm_put_heap(struct _seg_manager_t* self, reg_t reg, gint16 value);
-/* Writes a 16 bit value into a script's heap representation
-** Parameters: (reg_t) reg: The address to write to
-**	       (gint16) value: The value to write
-*/
-
-void
-sm_mcpy_in_out(seg_manager_t* self, int dst, const void* src, size_t n, int id, int flag);
-/* Copies a byte string into a script's heap representation
-** Parameters: (int) dst: The script-relative offset of the destination area
-**	       (const void *) src: Pointer to the data source location
-**	       (size_t) n: Number of bytes to copy
-**	       (int) id: ID of the script or script segment to write to
-**             (id_flag) flag: Whether to address the script by script number (SCRIPT_ID) or
-**				by its segment (SEG_ID). SEG_ID is faster than SCRIPT_ID,
-**				but less convenient.
-** A dynamic failure is issued if the specified ID does not reference a proper script.
-*/
-
-
-/*==============================================================*/
-/* 4. Stack							*/
-/*==============================================================*/
-
-dstack_t *
-sm_allocate_stack(struct _seg_manager_t *self, int size, seg_id_t *segid);
-/* Allocates a data stack
-** Parameters: (int) size: Number of stack entries to reserve
-** Returns   : (dstack_t *): The physical stack
-**             (seg_id_t) segid: Segment ID of the stack
-*/
-
-
-
-/*==============================================================*/
-/* 5. System Strings						*/
-/*==============================================================*/
-
-sys_strings_t *
-sm_allocate_sys_strings(struct _seg_manager_t *self, seg_id_t *segid);
-/* Allocates a system string table
-** Returns   : (dstack_t *): The physical stack
-**             (seg_id_t) segid: Segment ID of the stack
-** See also sys_string_acquire();
-*/
-
-
-
-/*==============================================================*/
-/* 6, 7. Lists and Nodes					*/
-/*==============================================================*/
-
-list_t*
-sm_alloc_list(struct _seg_manager_t *self, reg_t *addr);
-/* Allocate a fresh list
-** Returns : (listY_t*): Reference to the memory allocated for the list
-**           (reg_t) *addr: The offset of the freshly allocated list
-*/
-
-void
-sm_free_list(struct _seg_manager_t *self, reg_t addr);
-/* Deallocates a list
-** Parameters: (reg_t) addr: Offset of the list scheduled for termination
-*/
-
-
-node_t*
-sm_alloc_node(struct _seg_manager_t *self, reg_t *addr);
-/* Allocate a fresh node
-** Returns : (node_t*): Reference to the memory allocated for the node
-**           (reg_t) *addr: The offset of the freshly allocated node
-*/
-
-void
-sm_free_node(struct _seg_manager_t *self, reg_t addr);
-/* Deallocates a list node
-** Parameters: (reg_t) addr: Offset of the node scheduled for termination
-*/
-
-
-
-/*==============================================================*/
-/* 8. Hunk Memory						*/
-/*==============================================================*/
-
-hunk_t*
-sm_alloc_hunk_entry(struct _seg_manager_t *self, const char *hunk_type, int size, reg_t *addr);
-/* Allocate a fresh chunk of the hunk
-** Parameters: (int) size: Number of bytes to allocate for the hunk entry
-**             (const char *) hunk_type: A descriptive string for the hunk entry,
-**				for debugging purposes
-** Returns   : (hunk_t*): Reference to the memory allocated for the hunk piece
-**             (reg_t) *addr: The offset of the freshly allocated hunk entry
-*/
-
-void
-sm_free_hunk_entry(struct _seg_manager_t *self, reg_t addr);
-/* Deallocates a hunk eentry
-** Parameters: (reg_t) addr: Offset of the hunk entry to delete
-*/
-
-
-
-/*==============================================================*/
-/* 9. Dynamic Memory						*/
-/*==============================================================*/
-
-unsigned char *
-sm_alloc_dynmem(struct _seg_manager_t *self, int size, const char *description, reg_t *addr);
-/* Allocate some dynamic memory
-** Parameters: (int) size: Number of bytes to allocate
-**             (const char_ *) description: A descriptive string,
-**				for debugging purposes
-** Returns   : (unsigned char*): Raw pointer into the allocated dynamic memory
-**             (reg_t) *addr: The offset of the freshly allocated X
-*/
-
-int
-sm_free_dynmem(struct _seg_manager_t *self, reg_t addr);
-/* Deallocates a piece of dynamic memory
-** Parameters: (reg_t) addr: Offset of the dynmem chunk to free
-*/
-
-const char *
-sm_get_description(struct _seg_manager_t *self, reg_t addr);
-/* Gets the description of a dynmem segment
-** Parameters: (reg_t) addr: Segment to describe
-** Returns   : (const char *): Pointer to the descriptive string set in
-** sm_alloc_dynmem
-*/
-
-/*==============================================================*/
-/* 10. Reserved segments					*/
-/*==============================================================*/
-
-seg_id_t
-sm_allocate_reserved_segment(struct _seg_manager_t *self, char *name);
-/* Reserves a special-purpose segment
-** Parameters: (char *) name: A string name identifying the segment (the string is cloned and retained)
-** Returns   : A fresh segment ID for the segment in question
-** Reserved segments are never used by the segment manager.  They can be used to tag special-purpose addresses.
-** Segment 0 is implicitly reserved for numbers.
-*/
-
-/*==============================================================*/
-/* Generic Operations on Segments and Addresses			*/
-/*==============================================================*/
-
-byte *
-sm_dereference(struct _seg_manager_t *self, reg_t reg, int *size);
-/* Dereferences a raw memory pointer
-** Parameters: (reg_t) reg: The reference to dereference
-** Returns   : (byte *) The data block referenced
-**             (int) size: (optionally) the theoretical maximum size of it
-*/
-
-
-/*==============================================================*/
-/* 11. Segment interface, primarily for GC			*/
-/*==============================================================*/
-
-typedef struct _seg_interface {
-	seg_manager_t *segmgr;
-	mem_obj_t *mobj;
-	seg_id_t seg_id;
-	mem_obj_enum type_id;	/* Segment type */
-	const char *type;	/* String description of the segment type */
-
-	reg_t
-	(*find_canonic_address)(struct _seg_interface *self, reg_t sub_addr);
-	/* Finds the canonic address associated with sub_reg
-	** Parameters: (reg_t) sub_addr: The base address whose canonic address is to be found
-	** For each valid address a, there exists a canonic address c(a) such that c(a) = c(c(a)).
-	** This address "governs" a in the sense that deallocating c(a) will deallocate a.
-	*/
-
-	void
-	(*free_at_address)(struct _seg_interface *self, reg_t sub_addr);
-	/* Deallocates all memory associated with the specified address
-	** Parameters: (reg_t) sub_addr: The address (within the given segment) to deallocate
-	*/
-
-	void
-	(*list_all_deallocatable)(struct _seg_interface *self, void *param, void (*note)(void *param, reg_t addr));
-	/* Iterates over and reports all addresses within the current segment
-	** Parameters: note : (voidptr * addr) -> (): Invoked for each address on which free_at_address()
-	**                                makes sense
-	**             (void *) param: Parameter passed to 'note'
-	*/
-
-	void
-	(*list_all_outgoing_references)(struct _seg_interface *self, struct _state *s, reg_t object, void *param, void (*note)(void *param, reg_t addr));
-	/* Iterates over all references reachable from the specified object
-	** Parameters: (reg_t) object: The object (within the current segment) to analyse
-	**             (void *) param: Parameter passed to 'note'
-	**             note : (voidptr * addr) -> (): Invoked for each outgoing reference within the object
-	** Note: This function may also choose to report numbers (segment 0) as adresses
-	*/
-
-	void
-	(*deallocate_self)(struct _seg_interface *self);
-	/* Deallocates the segment interface
-	 */
-
-} seg_interface_t;
-
-seg_interface_t *
-get_seg_interface(seg_manager_t *self, seg_id_t segid);
-/* Retrieves the segment interface to the specified segment
-** Parameters: (seg_id_t) segid: ID of the segment to look up
-** Returns   : (seg_interface_t *): An interface to the specified segment ID, or NULL on error
-** The returned interface 'si' must be freed after use by calling 'si->dealloc_self(si)';
-*/
-
-
-
-#endif

Modified: scummvm/trunk/engines/sci/include/vm.h
===================================================================
--- scummvm/trunk/engines/sci/include/vm.h	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/include/vm.h	2009-02-16 09:40:25 UTC (rev 38360)
@@ -31,7 +31,7 @@
 #include "sci/include/script.h"
 #include "sci/include/vocabulary.h"
 #include "sci/include/versions.h"
-#include "sci/include/seg_manager.h"
+#include "sci/engine/seg_manager.h"
 #include "sci/include/vm_types.h"
 #include "sci/include/sys_strings.h"
 #include "sci/include/heapmgr.h"
@@ -113,7 +113,7 @@
 	reg_t reg; /* offset; script-relative offset, segment: 0 if not instantiated */
 } class_t;
 
-#define RAW_GET_CLASS_INDEX(scr, reg) (int_hash_map_check_value((scr)->obj_indices, reg.offset, 0, NULL))
+#define RAW_GET_CLASS_INDEX(scr, reg) ((scr)->obj_indices->check_value(reg.offset, false))
 #define RAW_IS_OBJECT(datablock) (getUInt16(((byte *) datablock) + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER)
 
 #define IS_CLASS(obj) (obj->variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)
@@ -180,7 +180,7 @@
 
 
 //#define VM_OBJECT_SET_INDEX(ptr, index) { ((byte *) (ptr))[0] = (index) & 0xff; ((byte *) (ptr))[1] = ((index) >> 8) & 0xff; }
-#define VM_OBJECT_GET_INDEX(scr, reg) (int_hash_map_check_value(scr->obj_indices, reg.offset, 0, NULL))
+//#define VM_OBJECT_GET_INDEX(scr, reg) (int_hash_map_check_value(scr->obj_indices, reg.offset, 0, NULL))
 
 typedef struct {
 	int nr; /* Script number */

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/module.mk	2009-02-16 09:40:25 UTC (rev 38360)
@@ -6,6 +6,7 @@
 	engine/game.o \
 	engine/gc.o \
 	engine/grammar.o \
+	engine/int_hashmap.o \
 	engine/kernel.o \
 	engine/kevent.o \
 	engine/kfile.o \
@@ -57,7 +58,6 @@
 	scicore/exe.o \
 	scicore/exe_lzexe.o \
 	scicore/exe_raw.o \
-	scicore/int_hashmap.o \
 	scicore/resource.o \
 	scicore/resource_map.o \
 	scicore/resource_patch.o \

Deleted: scummvm/trunk/engines/sci/scicore/hashmap.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/hashmap.cpp	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/scicore/hashmap.cpp	2009-02-16 09:40:25 UTC (rev 38360)
@@ -1,183 +0,0 @@
-/***************************************************************************
- hashmap.c Copyright (C) 2001 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
-    Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-/* Defines a universal hash map.
-** Preprocessor parameters:
-** TYPE: The type to hash
-** HASH_MAX: Maximum hash value
-** HASH(x): Hashes a value of type TYPE to an int from 0 to HASH_MAX
-*/
-#ifdef MUST_FREE
-#  define CLEAR_NODE(n) free(n->name); n->name = NULL
-#  define FREE_PARAM(n) free(n)
-#else
-#  define CLEAR_NODE(n)
-#  define FREE_PARAM(n)
-#endif
-
-
-#ifdef DUPLICATOR
-#  define DUP_VALUE(x) DUPLICATOR((x))
-#else
-#  define DUP_VALUE(x) (x)
-#endif
-
-
-#define DEFINE_FUNCTIONS(TYPE) \
-										\
-										\
-TYPE##_hash_map_t *								\
-new_##TYPE##_hash_map(void)							\
-{										\
-	TYPE##_hash_map_t *map = (TYPE##_hash_map_t*)calloc(1, sizeof(TYPE##_hash_map_t));\
-										\
-	return map;								\
-}										\
-                                                                \
-                                                                \
-static void							\
-print_##TYPE##_nodes(TYPE##_hash_map_node_t *node)		\
-{								\
-	while (node) {						\
-		fprintf(stderr,"%p  ", (void *)node);		\
-		node = node->next;				\
-	}							\
-}								\
-								\
-void								\
-print_##TYPE##_hash_map(TYPE##_hash_map_t *map)			\
-{								\
-	int bucket;						\
-	fprintf(stderr, #TYPE " map %p: base value=%d\n", (void *)map,  \
-		map->base_value);		                \
-	for (bucket = 0; bucket <= HASH_MAX; bucket++) {        \
-		fprintf(stderr,"bucket %d: ", bucket);		\
-		print_##TYPE##_nodes(map->nodes[bucket]);	\
-		fprintf(stderr,"\n");				\
-	}							\
-	fprintf(stderr,"holes: ");				\
-	print_##TYPE##_nodes(map->holes);			\
-	fprintf(stderr,"\n");					\
-}                                                               \
-                                                                \
-void														 \
-apply_to_##TYPE##_hash_map(TYPE##_hash_map_t *map, void *param, void (*note)(void *param, TYPE name, int value)) \
-{														 \
-	int i;													 \
-	for (i = 0; i < HASH_MAX; i++) {									 \
-		TYPE##_hash_map_node_t *node = map->nodes[i];							 \
-		while (node) {											 \
-			note(param, node->name, node->value);							 \
-			node = node->next;									 \
-		}												 \
-	}													 \
-}														 \
-														 \
-										\
-static void									\
-free_##TYPE##_hash_map_node_t##_recursive(TYPE##_hash_map_node_t *node)		\
-{										\
-	if (node) {								\
-		CLEAR_NODE(node);				                \
-		free_##TYPE##_hash_map_node_t##_recursive(node->next);		\
-		free(node);							\
-	}									\
-}										\
-										\
-										\
-void										\
-free_##TYPE##_hash_map(TYPE##_hash_map_t *map)					\
-{										\
-	int i;									\
-										\
-	for (i = 0; i <= HASH_MAX; i++)						\
-		free_##TYPE##_hash_map_node_t##_recursive(map->nodes[i]);	\
-										\
-	free_##TYPE##_hash_map_node_t##_recursive(map->holes);			\
-										\
-	map->base_value = -42000; /* Trigger problems for people who		\
-			     ** forget to loose the reference  */		\
-	free(map);								\
-}										\
-										\
-int										\
-TYPE##_hash_map_check_value(TYPE##_hash_map_t *map, TYPE value,                 \
-			    char add, char *was_added)                  	\
-{										\
-	TYPE##_hash_map_node_t **node = &(map->nodes[HASH(value)]);		\
-										\
-	while (*node && COMP(value, (*node)->name))				\
-		node = &((*node)->next);					\
-										\
-        if (was_added)								\
-                *was_added = 0;							\
-										\
-	if (*node) {								\
-		FREE_PARAM(value);						\
-		return (*node)->value;						\
-	}									\
-	/* Not found */								\
-										\
-	if (!add)								\
-		return -1;							\
-										\
-        if (was_added)								\
-                *was_added = 1;							\
-										\
-	if (map->holes) { /* Re-use old node */					\
-		(*node) = map->holes;						\
-		map->holes = (*node)->next;					\
-                (*node)->next = NULL;                                           \
-		(*node)->name = DUP_VALUE(value);				\
-	} else {								\
-		*node = (TYPE##_hash_map_node_t*)malloc(sizeof(TYPE##_hash_map_node_t));\
-		(*node)->name = DUP_VALUE(value);				\
-		(*node)->value = map->base_value++;				\
-                (*node)->next = NULL;                                           \
-	}									\
-										\
-	return (*node)->value;							\
-}										\
-										\
-										\
-int										\
-TYPE##_hash_map_remove_value(TYPE##_hash_map_t *map, TYPE value)		\
-{										\
-	TYPE##_hash_map_node_t **node = &(map->nodes[HASH(value)]);		\
-										\
-	while (*node && COMP(value, (*node)->name))				\
-		node = &((*node)->next);					\
-										\
-	if (*node) {								\
-		TYPE##_hash_map_node_t *oldnode = *node;			\
-		*node = (*node)->next;						\
-										\
-		oldnode->next = map->holes; /* Old node is now a 'hole' */	\
-		map->holes = oldnode;						\
-		return oldnode->value;						\
-	} else return -1; /* Not found */					\
-}										\
- 

Deleted: scummvm/trunk/engines/sci/scicore/int_hashmap.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/int_hashmap.cpp	2009-02-16 09:29:07 UTC (rev 38359)
+++ scummvm/trunk/engines/sci/scicore/int_hashmap.cpp	2009-02-16 09:40:25 UTC (rev 38360)
@@ -1,33 +0,0 @@
-/***************************************************************************
- int_hashmap. Copyright (C) 2001 Christoph Reichenbach
-
-
- This program may be modified and copied freely according to the terms of
- the GNU general public license (GPL), as long as the above copyright
- notice and the licensing information contained herein are preserved.
-
- Please refer to www.gnu.org for licensing details.
-
- This work is provided AS IS, without warranty of any kind, expressed or
- implied, including but not limited to the warranties of merchantibility,
- noninfringement, and fitness for a specific purpose. The author will not
- be held liable for any damage caused by this work or derivatives of it.
-
- By using this source code, you agree to the licensing terms as stated
- above.
-
-
- Please contact the maintainer for bug reports or inquiries.
-
- Current Maintainer:
-
-    Christoph Reichenbach (CR) <jameson at linuxgames.com>
-
-***************************************************************************/
-
-#define BUILD_MAP_FUNCTIONS
-#include "sci/include/int_hashmap.h"
-
-#include "sci/scicore/hashmap.cpp"
-
-DEFINE_FUNCTIONS(int)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list