From 70265291d62280c525adc317158e9f531e0147ff Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 17 Sep 2015 01:21:28 +0200 Subject: Cleanup of the HPluginData implementation (First part) - Several explicit casts are removed, to have a slightly better type-checking at compile time. - A destructor function is provided, to remove code duplication. Signed-off-by: Haru --- src/map/unit.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/unit.c b/src/map/unit.c index 04a8befc2..0f8a9d7e6 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2655,16 +2655,9 @@ int unit_free(struct block_list *bl, clr_type clrtype) { sd->num_quests = sd->avail_quests = 0; } - if (sd->hdata) { - unsigned int k; - for( k = 0; k < sd->hdatac; k++ ) { - if( sd->hdata[k]->flag.free ) { - aFree(sd->hdata[k]->data); - } - aFree(sd->hdata[k]); - } - aFree(sd->hdata); - } + HPM->data_store_destroy(sd->hdata); + sd->hdata = NULL; + break; } case BL_PET: @@ -2775,17 +2768,9 @@ int unit_free(struct block_list *bl, clr_type clrtype) { if( md->tomb_nid ) mob->mvptomb_destroy(md); - if (md->hdata) - { - unsigned int k; - for (k = 0; k < md->hdatac; k++) { - if( md->hdata[k]->flag.free ) { - aFree(md->hdata[k]->data); - } - aFree(md->hdata[k]); - } - aFree(md->hdata); - } + HPM->data_store_destroy(md->hdata); + md->hdata = NULL; + break; } case BL_HOM: -- cgit v1.2.3-60-g2f50