Mesa (master): intel: Allow intel_region_reference() with *dst != NULL.
Eric Anholt
anholt at kemper.freedesktop.org
Thu Jul 7 21:46:25 UTC 2011
Module: Mesa
Branch: master
Commit: 036b74a7f8adc745c7af089129f070b8e5b8f4bd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=036b74a7f8adc745c7af089129f070b8e5b8f4bd
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jun 29 11:09:49 2011 -0700
intel: Allow intel_region_reference() with *dst != NULL.
This should help us avoid leaking regions in region reference code by
making the API more predictable.
Reviewed-by: Chad Versace <chad at chad-versace.us>
---
src/mesa/drivers/dri/intel/intel_regions.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index a4da1ce..6cf37c4 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -264,11 +264,13 @@ intel_region_alloc_for_handle(struct intel_screen *screen,
void
intel_region_reference(struct intel_region **dst, struct intel_region *src)
{
- if (src)
- _DBG("%s %p %d\n", __FUNCTION__, src, src->refcount);
+ _DBG("%s: %p(%d) -> %p(%d)\n", __FUNCTION__,
+ *dst, *dst ? (*dst)->refcount : 0, src, src ? src->refcount : 0);
+
+ if (src != *dst) {
+ if (*dst)
+ intel_region_release(dst);
- assert(*dst == NULL);
- if (src) {
src->refcount++;
*dst = src;
}
More information about the mesa-commit
mailing list