summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-03 01:15:02 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-04 16:29:02 +0300
commit1246fcc42bc44f624a1c8bd855fd1dd82d51f228 (patch)
tree5ad659704c2f57711dc77e184e4110b527e12e79 /src
parent9b47893aa8736d173ca85a30c5336d9418b3044f (diff)
downloadplugin-1246fcc42bc44f624a1c8bd855fd1dd82d51f228.tar.gz
plugin-1246fcc42bc44f624a1c8bd855fd1dd82d51f228.tar.bz2
plugin-1246fcc42bc44f624a1c8bd855fd1dd82d51f228.tar.xz
plugin-1246fcc42bc44f624a1c8bd855fd1dd82d51f228.zip
Reduce memory usage in vectors.evolrelease2016-08-07
Diffstat (limited to 'src')
-rw-r--r--src/emap/craft.c2
-rw-r--r--src/emap/craftconf.c8
-rw-r--r--src/emap/itemdb.c4
-rw-r--r--src/emap/npc.c1
4 files changed, 8 insertions, 7 deletions
diff --git a/src/emap/craft.c b/src/emap/craft.c
index c33ec64..f9f6f54 100644
--- a/src/emap/craft.c
+++ b/src/emap/craft.c
@@ -205,7 +205,7 @@ struct craft_vardata *craft_str_to_craft(const char *craftstr)
strutil_free(craftdata);
return false;
}
- VECTOR_ENSURE(crslot->items, slot + 1, 1);
+ VECTOR_ENSURE(crslot->items, 1, 1);
VECTOR_INSERTZEROED(crslot->items, slot);
struct item_pair *pair = &VECTOR_INDEX(crslot->items, slot);
pair->index = index;
diff --git a/src/emap/craftconf.c b/src/emap/craftconf.c
index 0c9d329..7056d4f 100644
--- a/src/emap/craftconf.c
+++ b/src/emap/craftconf.c
@@ -100,7 +100,7 @@ static void craft_read_source_inventory(struct craft_db_entry *entry,
struct config_setting_t *item;
int invLen = VECTOR_LENGTH(entry->inventories);
- VECTOR_ENSURE(entry->inventories, invLen + 1, 1);
+ VECTOR_ENSURE(entry->inventories, 1, 1);
VECTOR_INSERTZEROED(entry->inventories, invLen);
struct craft_db_inventory *inventory = &VECTOR_INDEX(entry->inventories, invLen);
@@ -145,7 +145,7 @@ static void craft_read_create_items(struct craft_db_entry *entry,
struct config_setting_t *item;
int invLen = VECTOR_LENGTH(entry->create_items);
- VECTOR_ENSURE(entry->create_items, invLen + 1, 1);
+ VECTOR_ENSURE(entry->create_items, 1, 1);
VECTOR_INSERTZEROED(entry->create_items, invLen);
struct craft_items_collection *collection = &VECTOR_INDEX(entry->create_items, invLen);
VECTOR_INIT(*collection);
@@ -171,7 +171,7 @@ static void craft_read_create_items(struct craft_db_entry *entry,
continue;
}
- VECTOR_ENSURE(*collection, collecitonLen + 1, 1);
+ VECTOR_ENSURE(*collection, 1, 1);
VECTOR_INSERTZEROED(*collection, collecitonLen);
struct item_pair *pair = &VECTOR_INDEX(*collection, collecitonLen);
pair->index = itemId;
@@ -282,7 +282,7 @@ static void craft_read_items_collection(struct craft_db_entry *entry,
continue;
}
- VECTOR_ENSURE(*vector, len + 1, 1);
+ VECTOR_ENSURE(*vector, 1, 1);
VECTOR_INSERTZEROED(*vector, len);
struct item_pair *pair = &VECTOR_INDEX(*vector, len);
len ++;
diff --git a/src/emap/itemdb.c b/src/emap/itemdb.c
index 4c33853..366b05d 100644
--- a/src/emap/itemdb.c
+++ b/src/emap/itemdb.c
@@ -149,7 +149,7 @@ void eitemdb_readdb_additional_fields_pre(int *itemid,
continue;
const int val = libconfig->setting_get_int(it2);
- VECTOR_ENSURE(data->allowedCards, cnt + 1, 1);
+ VECTOR_ENSURE(data->allowedCards, 1, 1);
VECTOR_INSERTZEROED(data->allowedCards, cnt);
struct ItemCardExt *allowedCard = &VECTOR_INDEX(data->allowedCards, cnt);
@@ -178,7 +178,7 @@ void eitemdb_readdb_additional_fields_pre(int *itemid,
const char *name = config_setting_name(it2);
if (name && strncmp(name, "id", 2) && strncmp(name, "Id", 2))
continue;
- VECTOR_ENSURE(data->allowedAmmo, cnt + 1, 1);
+ VECTOR_ENSURE(data->allowedAmmo, 1, 1);
VECTOR_PUSH(data->allowedAmmo, atoi(name + 2));
cnt ++;
}
diff --git a/src/emap/npc.c b/src/emap/npc.c
index 59f41cf..e4c2427 100644
--- a/src/emap/npc.c
+++ b/src/emap/npc.c
@@ -181,6 +181,7 @@ bool enpc_duplicate_script_sub_pre(struct npc_data **ndPtr,
CREATE(code, struct script_code, 1);
const int sz = VECTOR_LENGTH(snd->u.scr.script->script_buf);
+ VECTOR_INIT(code->script_buf);
VECTOR_ENSURE(code->script_buf, sz , 1);
VECTOR_PUSHARRAY(code->script_buf, VECTOR_DATA(snd->u.scr.script->script_buf), sz);