[Scummvm-cvs-logs] CVS: scummvm config-file.cpp,1.4,1.5 main.cpp,1.11,1.12 resource.cpp,1.75,1.76 scumm.h,1.150,1.151 sound.cpp,1.69,1.70 sys.cpp,1.13,1.14

Lionel Ulmer bbrox at users.sourceforge.net
Wed May 1 10:35:37 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv19135

Modified Files:
	config-file.cpp main.cpp resource.cpp scumm.h sound.cpp 
	sys.cpp 
Log Message:
Removed ScummVM's private alloc / free / realloc functions. If I break
something, just yell :-)



Index: config-file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/config-file.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** config-file.cpp	28 Apr 2002 14:01:39 -0000	1.4
--- config-file.cpp	1 May 2002 17:16:45 -0000	1.5
***************
*** 73,77 ****
  hashconfig::~hashconfig()
  {
! 	Scumm::free(domain);
  }
  
--- 73,77 ----
  hashconfig::~hashconfig()
  {
! 	free(domain);
  }
  
***************
*** 100,104 ****
  	for (i = 0; i < nkeys; i++) {
  		if (!strcmp(key, keys[i])) {
! 			Scumm::free(values[i]);
  			return values[i] = value ? Scumm::Strdup(value) : 0;
  		}
--- 100,104 ----
  	for (i = 0; i < nkeys; i++) {
  		if (!strcmp(key, keys[i])) {
! 			free(values[i]);
  			return values[i] = value ? Scumm::Strdup(value) : 0;
  		}
***************
*** 106,111 ****
  
  	nkeys++;
! 	keys = (char **)Scumm::realloc(keys, nkeys * sizeof(char *));
! 	values = (char **)Scumm::realloc(values, nkeys * sizeof(char *));
  	keys[nkeys - 1] = Scumm::Strdup(key);
  	return values[nkeys - 1] = value ? Scumm::Strdup(value) : 0;
--- 106,111 ----
  
  	nkeys++;
! 	keys = (char **)realloc(keys, nkeys * sizeof(char *));
! 	values = (char **)realloc(values, nkeys * sizeof(char *));
  	keys[nkeys - 1] = Scumm::Strdup(key);
  	return values[nkeys - 1] = value ? Scumm::Strdup(value) : 0;
***************
*** 136,140 ****
  void hashconfig::rename(const char *d)
  {
! 	Scumm::free(domain);
  	domain = d ? Scumm::Strdup(d) : 0;
  }
--- 136,140 ----
  void hashconfig::rename(const char *d)
  {
! 	free(domain);
  	domain = d ? Scumm::Strdup(d) : 0;
  }
***************
*** 209,219 ****
  	int i;
  
! 	Scumm::free(filename);
! 	Scumm::free(domain);
  
  	for (i = 0; i < ndomains; i++) {
  		delete hash[i];
  	}
! 	Scumm::free(hash);
  }
  
--- 209,219 ----
  	int i;
  
! 	free(filename);
! 	free(domain);
  
  	for (i = 0; i < ndomains; i++) {
  		delete hash[i];
  	}
! 	free(hash);
  }
  
***************
*** 249,253 ****
  	ndomains++;
  	hash =
! 		(hashconfig **) Scumm::realloc(hash, ndomains * sizeof(hashconfig *));
  	hash[ndomains - 1] = new hashconfig(domain);
  
--- 249,253 ----
  	ndomains++;
  	hash =
! 		(hashconfig **) realloc(hash, ndomains * sizeof(hashconfig *));
  	hash[ndomains - 1] = new hashconfig(domain);
  
***************
*** 273,277 ****
  	ndomains++;
  	hash =
! 		(hashconfig **) Scumm::realloc(hash, ndomains * sizeof(hashconfig *));
  	hash[ndomains - 1] = new hashconfig(domain);
  
--- 273,277 ----
  	ndomains++;
  	hash =
! 		(hashconfig **) realloc(hash, ndomains * sizeof(hashconfig *));
  	hash[ndomains - 1] = new hashconfig(domain);
  
***************
*** 282,286 ****
  {
  	int i;
! 	Scumm::free(domain);
  	domain = d ? Scumm::Strdup(d) : 0;
  
--- 282,286 ----
  {
  	int i;
! 	free(domain);
  	domain = d ? Scumm::Strdup(d) : 0;
  
***************
*** 291,295 ****
  	ndomains++;
  	hash =
! 		(hashconfig **) Scumm::realloc(hash, ndomains * sizeof(hashconfig *));
  	hash[ndomains - 1] = new hashconfig(domain);
  }
--- 291,295 ----
  	ndomains++;
  	hash =
! 		(hashconfig **) realloc(hash, ndomains * sizeof(hashconfig *));
  	hash[ndomains - 1] = new hashconfig(domain);
  }
***************
*** 347,351 ****
  void Config::change_filename(const char *f)
  {
! 	Scumm::free(filename);
  	filename = f ? Scumm::Strdup(f) : 0;
  }
--- 347,351 ----
  void Config::change_filename(const char *f)
  {
! 	free(filename);
  	filename = f ? Scumm::Strdup(f) : 0;
  }
***************
*** 368,372 ****
  			ndomains++;
  			hash =
! 				(hashconfig **) Scumm::realloc(hash, ndomains * sizeof(hashconfig *));
  			hash[ndomains - 1] = new hashconfig(domain);
  			hash[ndomains - 1]->merge(c->hash[i]);
--- 368,372 ----
  			ndomains++;
  			hash =
! 				(hashconfig **) realloc(hash, ndomains * sizeof(hashconfig *));
  			hash[ndomains - 1] = new hashconfig(domain);
  			hash[ndomains - 1]->merge(c->hash[i]);

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/main.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** main.cpp	27 Apr 2002 21:06:48 -0000	1.11
--- main.cpp	1 May 2002 17:16:45 -0000	1.12
***************
*** 108,112 ****
  		char *s = detector.getGameName();
  		system->property(OSystem::PROP_SET_WINDOW_CAPTION, (long)s);
! 		Scumm::free(s);
  	}
  
--- 108,112 ----
  		char *s = detector.getGameName();
  		system->property(OSystem::PROP_SET_WINDOW_CAPTION, (long)s);
! 		free(s);
  	}
  

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** resource.cpp	27 Apr 2002 07:42:13 -0000	1.75
--- resource.cpp	1 May 2002 17:16:45 -0000	1.76
***************
*** 404,413 ****
  	res.tags[id] = tag;
  	res.name[id] = name;
! 	res.address[id] = (byte **)alloc(num * sizeof(void *));
! 	res.flags[id] = (byte *)alloc(num * sizeof(byte));
  
  	if (mode) {
! 		res.roomno[id] = (byte *)alloc(num * sizeof(byte));
! 		res.roomoffs[id] = (uint32 *)alloc(num * sizeof(uint32));
  	}
  }
--- 404,413 ----
  	res.tags[id] = tag;
  	res.name[id] = name;
! 	res.address[id] = (byte **)calloc(num, sizeof(void *));
! 	res.flags[id] = (byte *)calloc(num, sizeof(byte));
  
  	if (mode) {
! 		res.roomno[id] = (byte *)calloc(num, sizeof(byte));
! 		res.roomoffs[id] = (uint32 *)calloc(num, sizeof(uint32));
  	}
  }
***************
*** 751,755 ****
  	expireResources(size);
  
! 	CHECK_HEAP ptr = (byte *)alloc(size + sizeof(MemBlkHeader) + SAFETY_AREA);
  	if (ptr == NULL) {
  		error("Out of memory while allocating %d", size);
--- 751,755 ----
  	expireResources(size);
  
! 	CHECK_HEAP ptr = (byte *)calloc(size + sizeof(MemBlkHeader) + SAFETY_AREA, 1);
  	if (ptr == NULL) {
  		error("Out of memory while allocating %d", size);
***************
*** 1134,1138 ****
  		_numCostumes = fileReadWordLE();
  
! 		_objectRoomTable = (byte *)alloc(_numGlobalObjects);
  		_numGlobalScripts = 2000;
  
--- 1134,1138 ----
  		_numCostumes = fileReadWordLE();
  
! 		_objectRoomTable = (byte *)calloc(_numGlobalObjects, 1);
  		_numGlobalScripts = 2000;
  
***************
*** 1183,1187 ****
  
  	if (_shadowPaletteSize)
! 		_shadowPalette = (byte *)alloc(_shadowPaletteSize);
  
  	allocateArrays();
--- 1183,1187 ----
  
  	if (_shadowPaletteSize)
! 		_shadowPalette = (byte *)calloc(_shadowPaletteSize, 1);
  
  	allocateArrays();
***************
*** 1194,1208 ****
  	//     early GUI init.
  
! 	_objectOwnerTable = (byte *)alloc(_numGlobalObjects);
! 	_objectStateTable = (byte *)alloc(_numGlobalObjects);
! 	_classData = (uint32 *)alloc(_numGlobalObjects * sizeof(uint32));
! 	_arrays = (byte *)alloc(_numArray);
! 	_newNames = (uint16 *)alloc(_numNewNames * sizeof(uint16));
  
! 	_inventory = (uint16 *)alloc(_numInventory * sizeof(uint16));
! 	_verbs = (VerbSlot *)alloc(_numVerbs * sizeof(VerbSlot));
! 	_objs = (ObjectData *)alloc(_numLocalObjects * sizeof(ObjectData));
! 	_vars = (int16 *) alloc(_numVariables * sizeof(int16));
! 	_bitVars = (byte *)alloc(_numBitVariables >> 3);
  
  	allocResTypeData(rtCostume,
--- 1194,1208 ----
  	//     early GUI init.
  
! 	_objectOwnerTable = (byte *)calloc(_numGlobalObjects, 1);
! 	_objectStateTable = (byte *)calloc(_numGlobalObjects, 1);
! 	_classData = (uint32 *)calloc(_numGlobalObjects, sizeof(uint32));
! 	_arrays = (byte *)calloc(_numArray, 1);
! 	_newNames = (uint16 *)calloc(_numNewNames, sizeof(uint16));
  
! 	_inventory = (uint16 *)calloc(_numInventory, sizeof(uint16));
! 	_verbs = (VerbSlot *)calloc(_numVerbs, sizeof(VerbSlot));
! 	_objs = (ObjectData *)calloc(_numLocalObjects, sizeof(ObjectData));
! 	_vars = (int16 *) calloc(_numVariables, sizeof(int16));
! 	_bitVars = (byte *)calloc(_numBitVariables >> 3, 1);
  
  	allocResTypeData(rtCostume,

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.150
retrieving revision 1.151
diff -C2 -d -r1.150 -r1.151
*** scumm.h	29 Apr 2002 08:28:27 -0000	1.150
--- scumm.h	1 May 2002 17:16:45 -0000	1.151
***************
*** 1352,1358 ****
  	uint fileReadWordBE(void *handle);
  
- 	static byte *alloc(int size);
- 	static byte *realloc(void *mem, int size);
- 	static void free(void *mem);
  	static char *Strdup(const char *);
  
--- 1352,1355 ----

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** sound.cpp	1 May 2002 12:57:12 -0000	1.69
--- sound.cpp	1 May 2002 17:16:46 -0000	1.70
***************
*** 712,717 ****
  		fileSeek(_sfxFile, bundle_table[index].offset + table[i].offset, SEEK_SET);
  
! 		CompInput  = (unsigned char *)alloc(table[i].size);
! 		CompOutput = (unsigned char *)alloc(10000);
  		
  		fileRead((FILE *)_sfxFile, CompInput, table[i].size);
--- 712,717 ----
  		fileSeek(_sfxFile, bundle_table[index].offset + table[i].offset, SEEK_SET);
  
! 		CompInput  = (unsigned char *)malloc(table[i].size);
! 		CompOutput = (unsigned char *)malloc(10000);
  		
  		fileRead((FILE *)_sfxFile, CompInput, table[i].size);

Index: sys.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sys.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** sys.cpp	29 Apr 2002 08:28:27 -0000	1.13
--- sys.cpp	1 May 2002 17:16:46 -0000	1.14
***************
*** 202,249 ****
  }
  
- byte *Scumm::alloc(int size)
- {
- 	byte *me = (byte *)::calloc(size + 4, 1);
- 	if (me == NULL)
- 		return NULL;
- 
- 	*((uint32 *)me) = 0xDEADBEEF;
- 	return me + 4;
- }
- 
- void Scumm::free(void *mem)
- {
- 	if (mem) {
- 		byte *me = (byte *)mem - 4;
- 		if (*((uint32 *)me) != 0xDEADBEEF) {
- 			error("Freeing invalid block.");
- 		}
- 
- 		*((uint32 *)me) = 0xC007CAFE;
- 		::free(me);
- 	}
- }
- 
- byte *Scumm::realloc(void *mem, int size)
- {
- 	byte * me = (byte *) mem;
- 	if (mem) {
- 		if (size) {
- 			me = (byte *) ::realloc((me - 4), size + 4);
- 			return me + 4;
- 		} else {
- 			free(me);
- 			return NULL;
- 		}
- 	} else {
- 		return alloc(size);
- 	}
- }
- 
  char *Scumm::Strdup(const char *s)
  {
  	if (s) {
  		int l = strlen(s) + 1;
! 		char * r = (char *) alloc(l);
  		memcpy(r, s, l);
  		return r;
--- 202,210 ----
  }
  
  char *Scumm::Strdup(const char *s)
  {
  	if (s) {
  		int l = strlen(s) + 1;
! 		char * r = (char *) malloc(l);
  		memcpy(r, s, l);
  		return r;





More information about the Scummvm-git-logs mailing list