[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src ai/ccl_ai.c ai/new_ai.c clone/ccl...
From: |
ludovic pollet |
Subject: |
[Stratagus-CVS] stratagus/src ai/ccl_ai.c ai/new_ai.c clone/ccl... |
Date: |
Mon, 03 Nov 2003 06:21:46 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: ludovic pollet <address@hidden> 03/11/03 06:21:46
Modified files:
src/ai : ccl_ai.c new_ai.c
src/clone : ccl.c ccl_helpers.c mainloop.c
src/editor : editloop.c
src/game : loadgame.c trigger.c
src/include : ccl.h siod.h
src/siod : slib.c
src/unit : ccl_unittype.c unittype.c
Log message:
Fix GC problems with SIOD (patch #2237)
Patches:
Index: stratagus/src/ai/ccl_ai.c
diff -u stratagus/src/ai/ccl_ai.c:1.76 stratagus/src/ai/ccl_ai.c:1.77
--- stratagus/src/ai/ccl_ai.c:1.76 Sat Nov 1 06:37:34 2003
+++ stratagus/src/ai/ccl_ai.c Mon Nov 3 06:21:35 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_ai.c,v 1.76 2003/11/01 11:37:34 pludov Exp $
+// $Id: ccl_ai.c,v 1.77 2003/11/03 11:21:35 pludov Exp $
//@{
@@ -719,7 +719,7 @@
memset(aiScriptAction, 0, sizeof (AiScriptAction));
aiScriptAction->Action = definition;
- CclGcProtect(aiScriptAction->Action);
+ CclGcProtect(&aiScriptAction->Action);
while (!gh_null_p(type)) {
if (gh_eq_p(gh_car(type), gh_symbol2scm("defense"))) {
@@ -799,7 +799,7 @@
aitype->Script = value;
// Protect the scheme script against GC garbage-collect.
- CclGcProtect(value);
+ CclGcProtect(&aitype->Script);
return list;
}
Index: stratagus/src/ai/new_ai.c
diff -u stratagus/src/ai/new_ai.c:1.84 stratagus/src/ai/new_ai.c:1.85
--- stratagus/src/ai/new_ai.c:1.84 Sat Nov 1 06:30:42 2003
+++ stratagus/src/ai/new_ai.c Mon Nov 3 06:21:37 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: new_ai.c,v 1.84 2003/11/01 11:30:42 pludov Exp $
+// $Id: new_ai.c,v 1.85 2003/11/03 11:21:37 pludov Exp $
//@{
@@ -258,7 +258,7 @@
value = gh_eval(gh_car(AiScript->Script), NIL);
if (!gh_eq_p(value, SCM_BOOL_T)) {
- AiScript->Script = gh_cdr(AiScript->Script);
+ CclGcProtectedAssign(&AiScript->Script,
gh_cdr(AiScript->Script));
}
if ((gh_null_p(AiScript->Script)) && (AiScript->ownForce)) {
@@ -764,7 +764,7 @@
{
CLprintf(file, "\n;;; -----------------------------------------\n");
CLprintf(file,
- ";;; MODULE: AI $Id: new_ai.c,v 1.84 2003/11/01 11:30:42 pludov Exp
$\n\n");
+ ";;; MODULE: AI $Id: new_ai.c,v 1.85 2003/11/03 11:21:37 pludov Exp
$\n\n");
SaveAiTypesWcName(file);
SaveAiHelper(file);
@@ -805,6 +805,7 @@
pai->Scripts[i].gauges = 0;
pai->Scripts[i].SleepCycles = 0;
pai->Scripts[i].Script = NIL;
+ CclGcProtect(&pai->Scripts[i].Script);
snprintf(pai->Scripts[i].ident, 10, "Empty");
}
@@ -871,7 +872,7 @@
_C_ ainame _C_ ait->Class);
pai->AiType = ait;
- pai->Scripts[0].Script = ait->Script;
+ CclGcProtectedAssign(&pai->Scripts[0].Script, ait->Script);
pai->Collect[TimeCost] = 0;
pai->Collect[GoldCost] = 50;
@@ -924,6 +925,11 @@
free(aiunit);
}
}
+
+ for (i = 0; i < AI_MAX_RUNNING_SCRIPTS; ++i) {
+ CclGcUnprotect(&pai->Scripts[i].Script);
+ }
+
//
// Free UnitTypeRequests
//
@@ -968,6 +974,7 @@
free(aitype->Class);
// ai-type->Script freed by ccl
+ CclGcUnprotect(&aitype->Script);
temp = aitype->Next;
free(aitype);
@@ -1025,9 +1032,13 @@
AiTypeWcNames = NULL;
}
+ // Free script action scm...
+ for (i = 0; i < AiScriptActionNum; i++) {
+ CclGcUnprotect(&AiScriptActions[i].Action);
+ }
+
AiResetUnitTypeEquiv();
-
- // TODO : AiScriptActions are not freed
+
AiScriptActionNum = 0;
}
@@ -1212,7 +1223,6 @@
DebugCheck(unit->Player->Type == PlayerPerson);
// FIXME: must handle all orders...
-
switch (unit->Orders[0].Action) {
case UnitActionStill:
case UnitActionAttack:
Index: stratagus/src/clone/ccl.c
diff -u stratagus/src/clone/ccl.c:1.122 stratagus/src/clone/ccl.c:1.123
--- stratagus/src/clone/ccl.c:1.122 Fri Oct 31 04:14:46 2003
+++ stratagus/src/clone/ccl.c Mon Nov 3 06:21:38 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl.c,v 1.122 2003/10/31 09:14:46 pludov Exp $
+// $Id: ccl.c,v 1.123 2003/11/03 11:21:38 pludov Exp $
//@{
@@ -74,6 +74,14 @@
----------------------------------------------------------------------------*/
#ifdef USE_GUILE
+#define GC_PROTECT_VALUE 1
+#endif
+
+#ifdef SIOD_HEAP_GC
+#define GC_PROTECT_VALUE 1
+#endif
+
+#ifdef USE_GUILE
int siod_verbose_level;
#endif
@@ -197,20 +205,38 @@
return new_type;
}
+
+#ifdef GC_PROTECT_VALUE
+local int CclNeedProtect(SCM val)
+{
+ return (val != SCM_UNSPECIFIED) && (!gh_null_p(val));
+}
+#endif
+
/**
** Protect SCM object against garbage collector.
**
** @param obj Scheme object
*/
-global void CclGcProtect(SCM obj)
+global void CclGcProtect(SCM * obj)
{
+#ifdef GC_PROTECT_VALUE
+ if (!CclNeedProtect(*obj)) {
+ return;
+ }
+#endif
+
#ifdef USE_GUILE
- scm_gc_protect_object(obj);
+ scm_gc_protect_object(*obj);
#else
+#ifdef SIOD_HEAP_GC
SCM var;
var = gh_symbol2scm("*ccl-protect*");
setvar(var, cons(obj, symbol_value(var, NIL)), NIL);
+#else
+ gc_protect(obj);
+#endif
#endif
}
@@ -219,11 +245,17 @@
**
** @param obj Scheme object
*/
-global void CclGcUnprotect(SCM obj)
+global void CclGcUnprotect(SCM * obj)
{
+#ifdef GC_PROTECT_VALUE
+ if (!CclNeedProtect(*obj)) {
+ return;
+ }
+#endif
#ifdef USE_GUILE
- scm_gc_unprotect_object(obj);
+ scm_gc_unprotect_object(*obj);
#else
+#ifdef SIOD_HEAP_GC
SCM sym;
SCM old_lst;
SCM new_lst;
@@ -238,16 +270,28 @@
SCM el;
el = gh_car(old_lst);
- if (el != obj) {
+ if (el != (*obj)) {
new_lst = cons(el, new_lst);
}
old_lst = gh_cdr(old_lst);
}
setvar(sym, new_lst, NIL);
+#else
+ gc_unprotect(obj);
+#endif
#endif
}
+global void CclGcProtectedAssign(SCM* obj, SCM value)
+{
+#ifdef GC_PROTECT_VALUE
+ CclGcProtect(&value);
+ CclGcUnprotect(obj);
+#endif
+ (*obj) = value;
+}
+
global void CclFlushOutput(void)
{
#ifdef USE_GUILE
@@ -257,6 +301,33 @@
#endif
}
+/**
+** Perform CCL garbage collection
+**
+** @param fast set this flag to disable slow GC ( during game )
+*/
+global void CclGarbageCollect(int fast)
+{
+#ifdef USE_GUILE
+ if (!fast) {
+ // GUILE handle gc nicely by itself
+ scm_gc();
+ }
+#else
+#ifdef SIOD_HEAP_GC
+ static int cpt=0;
+
+ // Very slow, so differ...
+ if (!(++cpt & 15)) {
+ user_gc(SCM_BOOL_F);
+ }
+#else
+ // stop and copy iterates only the allocated SCM
+ gc_stop_and_copy();
+#endif
+#endif
+}
+
/*............................................................................
.. Config
............................................................................*/
@@ -845,8 +916,15 @@
sargv[0] = "Stratagus";
sargv[1] = "-v1";
+#ifdef SIOD_HEAP_GC
+ // Mark & sweep GC : scan the heap entirely
sargv[2] = "-g0";
sargv[3] = "-h800000:10";
+#else
+ // Stop & copy GC : scan only allocated cells
+ sargv[2] = "-g1";
+ sargv[3] = "-h800000";
+#endif
buf = malloc(strlen(StratagusLibPath) + 4);
sprintf(buf, "-l%s", StratagusLibPath);
sargv[4] = buf; // never freed
@@ -1056,7 +1134,7 @@
}
fprintf(fd, ";;; -----------------------------------------\n");
- fprintf(fd, ";;; $Id: ccl.c,v 1.122 2003/10/31 09:14:46 pludov Exp $\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.123 2003/11/03 11:21:38 pludov Exp $\n");
fprintf(fd, "(set-video-resolution! %d %d)\n", VideoWidth, VideoHeight);
@@ -1081,7 +1159,7 @@
}
fprintf(fd, ";;; -----------------------------------------\n");
- fprintf(fd, ";;; $Id: ccl.c,v 1.122 2003/10/31 09:14:46 pludov Exp $\n");
+ fprintf(fd, ";;; $Id: ccl.c,v 1.123 2003/11/03 11:21:38 pludov Exp $\n");
// Global options
if (OriginalFogOfWar) {
@@ -1175,7 +1253,7 @@
}
LoadPreferences2();
CclInConfigFile = 0;
- user_gc(SCM_BOOL_F); // Cleanup memory after load
+ CclGarbageCollect(0); // Cleanup memory after load
}
/**
@@ -1192,7 +1270,7 @@
extern SCM oblistvar;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.122 2003/10/31 09:14:46
pludov Exp $\n\n");
+ CLprintf(file, ";;; MODULE: CCL $Id: ccl.c,v 1.123 2003/11/03 11:21:38
pludov Exp $\n\n");
for (list = oblistvar; gh_list_p(list); list = gh_cdr(list)) {
SCM sym;
Index: stratagus/src/clone/ccl_helpers.c
diff -u stratagus/src/clone/ccl_helpers.c:1.5
stratagus/src/clone/ccl_helpers.c:1.6
--- stratagus/src/clone/ccl_helpers.c:1.5 Sun Oct 26 10:34:59 2003
+++ stratagus/src/clone/ccl_helpers.c Mon Nov 3 06:21:38 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_helpers.c,v 1.5 2003/10/26 15:34:59 pludov Exp $
+// $Id: ccl_helpers.c,v 1.6 2003/11/03 11:21:38 pludov Exp $
//@{
@@ -420,7 +420,8 @@
ptr = (SCM *) binaryform;
if (IOLoadingMode) {
*ptr = scmfrom;
- CclGcProtect(*ptr);
+ // FIXME : wrong place to prevent GC ?
+ CclGcProtect(ptr);
} else {
CLprintf(IOOutFile, " ");
lprin1CL(*ptr, IOOutFile);
Index: stratagus/src/clone/mainloop.c
diff -u stratagus/src/clone/mainloop.c:1.154
stratagus/src/clone/mainloop.c:1.155
--- stratagus/src/clone/mainloop.c:1.154 Mon Nov 3 06:09:49 2003
+++ stratagus/src/clone/mainloop.c Mon Nov 3 06:21:38 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mainloop.c,v 1.154 2003/11/03 11:09:49 pludov Exp $
+// $Id: mainloop.c,v 1.155 2003/11/03 11:21:38 pludov Exp $
//@{
@@ -840,7 +840,7 @@
}
// Clear scheme heap each second
// FIXME: this is too slow to call during the game
- //user_gc(SCM_BOOL_F);
+ CclGarbageCollect(1);
break;
case 1:
HandleCloak();
Index: stratagus/src/editor/editloop.c
diff -u stratagus/src/editor/editloop.c:1.139
stratagus/src/editor/editloop.c:1.140
--- stratagus/src/editor/editloop.c:1.139 Mon Nov 3 06:09:51 2003
+++ stratagus/src/editor/editloop.c Mon Nov 3 06:21:39 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: editloop.c,v 1.139 2003/11/03 11:09:51 pludov Exp $
+// $Id: editloop.c,v 1.140 2003/11/03 11:21:39 pludov Exp $
//@{
@@ -1815,7 +1815,7 @@
} else {
vload(file, 0, 1);
}
- user_gc(SCM_BOOL_F); // Cleanup memory after load
+ CclGarbageCollect(0); // Cleanup memory after load
}
ThisPlayer = &Players[0];
Index: stratagus/src/game/loadgame.c
diff -u stratagus/src/game/loadgame.c:1.66 stratagus/src/game/loadgame.c:1.67
--- stratagus/src/game/loadgame.c:1.66 Fri Oct 31 04:14:47 2003
+++ stratagus/src/game/loadgame.c Mon Nov 3 06:21:40 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: loadgame.c,v 1.66 2003/10/31 09:14:47 pludov Exp $
+// $Id: loadgame.c,v 1.67 2003/11/03 11:21:40 pludov Exp $
//@{
@@ -224,11 +224,11 @@
old_siod_verbose_level = siod_verbose_level;
siod_verbose_level = 4;
- user_gc(SCM_BOOL_F);
+ CclGarbageCollect(0);
siod_verbose_level = old_siod_verbose_level;
InitVisionTable();
gh_load(filename);
- user_gc(SCM_BOOL_F);
+ CclGarbageCollect(0);
game_cycle = GameCycle;
// FIXME: log should be loaded from the save game
Index: stratagus/src/game/trigger.c
diff -u stratagus/src/game/trigger.c:1.44 stratagus/src/game/trigger.c:1.45
--- stratagus/src/game/trigger.c:1.44 Thu Oct 2 11:39:32 2003
+++ stratagus/src/game/trigger.c Mon Nov 3 06:21:40 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: trigger.c,v 1.44 2003/10/02 15:39:32 jsalmon3 Exp $
+// $Id: trigger.c,v 1.45 2003/11/03 11:21:40 pludov Exp $
//@{
@@ -931,9 +931,9 @@
num = gh_scm2int(number);
if (num == -1) {
- Trigger = NULL;
+ CclGcProtectedAssign(&Trigger, NULL);
} else {
- Trigger = symbol_value(gh_symbol2scm("*triggers*"), NIL);
+ CclGcProtectedAssign(&Trigger,
symbol_value(gh_symbol2scm("*triggers*"), NIL));
if (gh_null_p(Trigger)) {
DebugLevel0Fn("Invalid trigger number: %d out of -1\n" _C_ num);
} else {
@@ -943,7 +943,7 @@
num _C_ i - 1);
break;
}
- Trigger = gh_cdr(Trigger);
+ CclGcProtectedAssign(&Trigger, gh_cdr(Trigger));
}
}
}
@@ -968,7 +968,7 @@
value = gh_eval(gh_car(script), NIL);
script = gh_cdr(script);
if (WaitFrame > FrameCounter) {
- WaitScript = script;
+ CclGcProtectedAssign(&WaitScript, script);
return 0;
}
}
@@ -994,7 +994,7 @@
gh_set_car_x(trig, NIL);
gh_set_cdr_x(trig, NIL);
}
- Trigger = trig;
+ CclGcProtectedAssign(&Trigger, trig);
}
/**
@@ -1008,7 +1008,7 @@
SCM script;
if (!Trigger) {
- Trigger = symbol_value(gh_symbol2scm("*triggers*"), NIL);
+ CclGcProtectedAssign(&Trigger,
symbol_value(gh_symbol2scm("*triggers*"), NIL));
}
trig = Trigger;
@@ -1029,8 +1029,8 @@
if (!gh_null_p(trig)) { // Next trigger
pair = gh_car(trig);
- Trigger = gh_cdr(trig);
- WaitTrigger = trig;
+ CclGcProtectedAssign(&Trigger, gh_cdr(trig));
+ CclGcProtectedAssign(&WaitTrigger, trig);
// Pair is condition action
if (!gh_null_p(pair)) {
script = gh_car(pair);
@@ -1047,7 +1047,7 @@
}
}
} else {
- Trigger = NULL;
+ CclGcProtectedAssign(&Trigger, NULL);
}
}
@@ -1056,6 +1056,12 @@
*/
global void TriggerCclRegister(void)
{
+ Trigger = NIL;
+ WaitScript = NIL;
+ WaitTrigger = NIL;
+ CclGcProtect(&Trigger);
+ CclGcProtect(&WaitScript);
+ CclGcProtect(&WaitTrigger);
gh_new_procedure2_0("add-trigger", CclAddTrigger);
gh_new_procedure1_0("set-trigger-number!", CclSetTriggerNumber);
// Conditions
@@ -1186,7 +1192,7 @@
int trigger;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.44 2003/10/02
15:39:32 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: trigger $Id: trigger.c,v 1.45 2003/11/03
11:21:40 pludov Exp $\n\n");
i = 0;
trigger = -1;
@@ -1246,7 +1252,7 @@
var = gh_symbol2scm("*triggers*");
setvar(var, NIL, NIL);
- Trigger = NULL;
+ CclGcProtectedAssign(&Trigger, NULL);
memset(&GameTimer, 0, sizeof(GameTimer));
}
Index: stratagus/src/include/ccl.h
diff -u stratagus/src/include/ccl.h:1.40 stratagus/src/include/ccl.h:1.41
--- stratagus/src/include/ccl.h:1.40 Fri Oct 31 04:14:48 2003
+++ stratagus/src/include/ccl.h Mon Nov 3 06:21:41 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl.h,v 1.40 2003/10/31 09:14:48 pludov Exp $
+// $Id: ccl.h,v 1.41 2003/11/03 11:21:41 pludov Exp $
#ifndef __CCL_H__
#define __CCL_H__
@@ -57,7 +57,6 @@
# define aset1(array, pos, value) gh_vector_set_x(array, pos, value)
# define repl_c_string(msg, a, b, c ) gh_eval_str(msg)
# define print_welcome()
-# define user_gc(a) scm_gc()
# define gh_scm2newstr(scm, lenp) \
(gh_symbol_p(scm) ? gh_symbol2newstr(scm, lenp) : gh_scm2newstr(scm,lenp))
# define gh_scm2int(val) \
@@ -170,8 +169,10 @@
extern void* CclGetSmobData(SCM smob);
extern ccl_smob_type_t CclGetSmobType(SCM smob);
-extern void CclGcProtect(SCM obj); /// Protect scm object for GC
-extern void CclGcUnprotect(SCM obj); /// Unprotect scm object for GC
+extern void CclGcProtect(SCM* obj); /// Protect scm var for GC
+extern void CclGcUnprotect(SCM* obj); /// Unprotect scm var for GC
+extern void CclGcProtectedAssign(SCM* obj, SCM value); /// Alter garbage
protected scm var.
+extern void CclGarbageCollect(int fast);/// Perform garbage collection
extern void CclFlushOutput(); /// Flush ccl output
extern void InitCcl(void); /// Initialise ccl
extern void LoadCcl(void); /// Load ccl config file
Index: stratagus/src/include/siod.h
diff -u stratagus/src/include/siod.h:1.8 stratagus/src/include/siod.h:1.9
--- stratagus/src/include/siod.h:1.8 Sun Aug 17 11:57:07 2003
+++ stratagus/src/include/siod.h Mon Nov 3 06:21:41 2003
@@ -4,7 +4,7 @@
* PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS. *
* See the source file SLIB.C for more information. *
- $Id: siod.h,v 1.8 2003/08/17 15:57:07 n0body Exp $
+ $Id: siod.h,v 1.9 2003/11/03 11:21:41 pludov Exp $
*/
@@ -206,6 +206,7 @@
LISP subrcons(long type, char *name, SUBR_FUNC f);
LISP closure(LISP env,LISP code);
void gc_protect(LISP *location);
+void gc_unprotect(LISP *location);
void gc_protect_n(LISP *location,long n);
void gc_protect_sym(LISP *location,char *st);
Index: stratagus/src/siod/slib.c
diff -u stratagus/src/siod/slib.c:1.31 stratagus/src/siod/slib.c:1.32
--- stratagus/src/siod/slib.c:1.31 Wed Oct 15 21:36:25 2003
+++ stratagus/src/siod/slib.c Mon Nov 3 06:21:41 2003
@@ -91,7 +91,7 @@
static void init_slib_version(void)
{setvar(cintern("*slib-version*"),
- cintern("$Id: slib.c,v 1.31 2003/10/16 01:36:25 jsalmon3 Exp $"),
+ cintern("$Id: slib.c,v 1.32 2003/11/03 11:21:41 pludov Exp $"),
NIL);}
char * __stdcall siod_version(void)
@@ -1006,6 +1006,20 @@
(*reg).next = protected_registers;
protected_registers = reg;}
+void gc_unprotect(LISP * location)
+{struct gc_protected * reg, ** ptr;
+ ptr=&protected_registers;
+ while(*ptr){
+ if ((*ptr)->location==location){
+ reg=(*ptr);
+ *ptr=reg->next;
+ free(reg);
+ }else{
+ ptr=&((*ptr)->next);
+ }
+ }
+}
+
void gc_protect_sym(LISP *location,char *st)
{*location = cintern(st);
gc_protect(location);}
Index: stratagus/src/unit/ccl_unittype.c
diff -u stratagus/src/unit/ccl_unittype.c:1.107
stratagus/src/unit/ccl_unittype.c:1.108
--- stratagus/src/unit/ccl_unittype.c:1.107 Sun Nov 2 14:24:25 2003
+++ stratagus/src/unit/ccl_unittype.c Mon Nov 3 06:21:43 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_unittype.c,v 1.107 2003/11/02 19:24:25 jsalmon3 Exp $
+// $Id: ccl_unittype.c,v 1.108 2003/11/03 11:21:43 pludov Exp $
//@{
@@ -138,6 +138,9 @@
type->NumDirections = 8;
+ type->Property = SCM_UNSPECIFIED;
+ CclGcProtect((SCM*)&type->Property);
+
//
// Parse the list: (still everything could be changed!)
//
@@ -938,14 +941,10 @@
type = CclGetUnitType(ptr);
- if (type->Property) {
- // FIXME: old value must be unprotected!!
- }
if (!property) {
DebugLevel0Fn("oops, my fault\n");
}
- type->Property = property;
- CclGcProtect(type->Property);
+ CclGcProtectedAssign((SCM*)&type->Property, property);
return property;
}
Index: stratagus/src/unit/unittype.c
diff -u stratagus/src/unit/unittype.c:1.122 stratagus/src/unit/unittype.c:1.123
--- stratagus/src/unit/unittype.c:1.122 Sat Nov 1 23:20:38 2003
+++ stratagus/src/unit/unittype.c Mon Nov 3 06:21:45 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unittype.c,v 1.122 2003/11/02 04:20:38 jsalmon3 Exp $
+// $Id: unittype.c,v 1.123 2003/11/03 11:21:45 pludov Exp $
//@{
@@ -1188,7 +1188,7 @@
char** sp;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: unittypes $Id: unittype.c,v 1.122 2003/11/02
04:20:38 jsalmon3 Exp $\n\n");
+ CLprintf(file, ";;; MODULE: unittypes $Id: unittype.c,v 1.123 2003/11/03
11:21:45 pludov Exp $\n\n");
// Original number to internal unit-type name.
@@ -1521,7 +1521,7 @@
free(type->BoolFlag);
free(type->CanTargetFlag);
-
+ CclGcUnprotect((SCM*)&type->Property);
if (type->SameSprite) {
free(type->SameSprite);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src ai/ccl_ai.c ai/new_ai.c clone/ccl...,
ludovic pollet <=