From: Dave Airlie Date: Thu, 22 Jan 2009 11:47:38 +0000 (+1000) Subject: radeon: free all relocs in array X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=860d0cc656ee0eb724b2d82596c09a9eee9a8d19;p=mesa.git radeon: free all relocs in array --- diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c index b9751248280..1f07c1c6c4f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c +++ b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c @@ -135,7 +135,7 @@ static int cs_write_reloc(struct radeon_cs *cs, relocs[i].base.read_domain |= read_domain; relocs[i].base.write_domain |= write_domain; /* save indice */ - relocs[i].cindices += 1; + relocs[i].cindices++; indices = (uint32_t*)realloc(relocs[i].indices, relocs[i].cindices * 4); if (indices == NULL) { @@ -335,16 +335,21 @@ static int cs_emit(struct radeon_cs *cs) return 0; } -static void inline cs_free_reloc(void *relocs_p) +static void inline cs_free_reloc(void *relocs_p, int crelocs) { struct cs_reloc_legacy *relocs = relocs_p; - if (relocs) - free(relocs->indices); + int i; + + for (i = 0; i < crelocs; i++) { + struct cs_reloc_legacy *ptr = relocs[i]; + if (ptr) + free(ptr->indices); + } } static int cs_destroy(struct radeon_cs *cs) { - cs_free_reloc(cs->relocs); + cs_free_reloc(cs->relocs, cs->crelocs); free(cs->relocs); free(cs->packets); free(cs); @@ -353,7 +358,7 @@ static int cs_destroy(struct radeon_cs *cs) static int cs_erase(struct radeon_cs *cs) { - cs_free_reloc(cs->relocs); + cs_free_reloc(cs->relocs, cs->crelocs); free(cs->relocs); cs->relocs_total_size = 0; cs->relocs = NULL;