Browse Source

Fix a refcount bug in the entity dictionary.

legacy
Sam Hocevar sam 14 years ago
parent
commit
be70a70eaa
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      src/dict.cpp

+ 10
- 1
src/dict.cpp View File

@@ -40,8 +40,10 @@ public:


~DictData() ~DictData()
{ {
#if !FINAL_RELEASE
if (nentities) if (nentities)
fprintf(stderr, "ERROR: still %i entities in dict\n", nentities); fprintf(stderr, "ERROR: still %i entities in dict\n", nentities);
#endif
free(entities); free(entities);
} }


@@ -103,8 +105,15 @@ int Dict::MakeSlot(char const *name)
void Dict::RemoveSlot(int id) void Dict::RemoveSlot(int id)
{ {
if (Ticker::Unref(data->entities[id]) == 0) if (Ticker::Unref(data->entities[id]) == 0)
{
data->entities[id] = NULL; data->entities[id] = NULL;
data->nentities--;
if (data->nentities)
data->nentities--;
#if !FINAL_RELEASE
else
fprintf(stderr, "ERROR: removing entity from empty dict\n");
#endif
}
} }






Loading…
Cancel
Save