From 506e8531a95fc953c8fa5193909290aa6ffd88dc Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Wed, 10 Jun 2009 15:13:45 +1000
Subject: [PATCH] glx: fix open-coded linked list removal function

OMG stab stab stab, YALL.

removal function was made of crack, actually truncated the list from
the one after the find point.

However fixing this makes glean makecurrent fail with a GLX error.
---
 glx/glxext.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/glx/glxext.c b/glx/glxext.c
index bdacf88..324165d 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -150,12 +150,18 @@ void __glXAddToContextList(__GLXcontext *cx)
 
 void __glXRemoveFromContextList(__GLXcontext *cx)
 {
-    __GLXcontext *c, **prev;
+    __GLXcontext *c, *prev;
 
-    prev = &glxAllContexts;
-    for (c = glxAllContexts; c; c = c->next)
-	if (c == cx)
-	    *prev = c->next;
+    if (cx == glxAllContexts)
+	glxAllContexts = cx->next;
+    else {
+	prev = glxAllContexts;
+    	for (c = glxAllContexts; c; c = c->next) {
+		if (c == cx)
+	    		prev->next = c->next;
+		prev = c;
+	}
+    }
 }
 
 /*
-- 
1.6.2.2

