From 88d59f6ff3769aa4e0f2a221ecea22fd86413115 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 16 Aug 2009 18:07:57 +0100 Subject: Map counting fixes --- glamo/glamo_bo_gem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/glamo/glamo_bo_gem.c b/glamo/glamo_bo_gem.c index 048f477c..e76f9aa6 100644 --- a/glamo/glamo_bo_gem.c +++ b/glamo/glamo_bo_gem.c @@ -174,6 +174,10 @@ static struct glamo_bo *bo_unref(struct glamo_bo *bo) return bo; } if (bo_gem->map_count) { + fprintf(stderr, "Map count for %p isn't zero (=%i)," + " so I am unmapping it (%p, %i)\n", + bo_gem, bo_gem->map_count, bo->virtual, + bo->size); munmap(bo->virtual, bo->size); } @@ -224,6 +228,7 @@ static int bo_map(struct glamo_bo *bo, int write) strerror(errno)); return errno; } + bo_gem->map_count++; } return 0; @@ -233,6 +238,12 @@ static int bo_unmap(struct glamo_bo *bo) { struct glamo_bo_gem *bo_gem = (struct glamo_bo_gem*)bo; + if ( bo_gem->map_count == 0 ) { + fprintf(stderr, "Not unmapping %p, because its map count" + " is already zero.\n", bo_gem); + return 0; + } + if (--bo_gem->map_count > 0) { return 0; } -- cgit v1.2.3