apple: Fix a use after free
[mesa.git] / src / glx / apple / apple_xgl_api_read.c
index 0798f45bbfb8a7d18a43f4858af6a3edfb7c8999..612f5f7b01fa8955beb849072638e20ed4979532 100644 (file)
@@ -1,5 +1,5 @@
 /*
- Copyright (c) 2008, 2009 Apple Inc.
+ Copyright (c) 2008-2011 Apple Inc.
  
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation files
@@ -37,8 +37,9 @@
 #include "glxclient.h"
 #include "apple_glx_context.h"
 #include "apple_xgl_api.h"
+#include "glapitable.h"
 
-extern struct apple_xgl_api __gl_api;
+extern struct _glapi_table * __ogl_framework_api;
 
 struct apple_xgl_saved_state
 {
@@ -48,7 +49,7 @@ struct apple_xgl_saved_state
 static void
 SetRead(struct apple_xgl_saved_state *saved)
 {
-   GLXContext gc = __glXGetCurrentContext();
+   struct glx_context *gc = __glXGetCurrentContext();
 
    /*
     * By default indicate that the state was not swapped, so that UnsetRead
@@ -81,7 +82,7 @@ static void
 UnsetRead(struct apple_xgl_saved_state *saved)
 {
    if (saved->swapped) {
-      GLXContext gc = __glXGetCurrentContext();
+      struct glx_context *gc = __glXGetCurrentContext();
       Display *dpy = glXGetCurrentDisplay();
 
       if (apple_glx_make_current_context(dpy, gc->driContext, gc->driContext,
@@ -95,39 +96,39 @@ UnsetRead(struct apple_xgl_saved_state *saved)
 }
 
 void
-glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+__applegl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
              GLenum format, GLenum type, void *pixels)
 {
    struct apple_xgl_saved_state saved;
 
    SetRead(&saved);
 
-   __gl_api.ReadPixels(x, y, width, height, format, type, pixels);
+   __ogl_framework_api->ReadPixels(x, y, width, height, format, type, pixels);
 
    UnsetRead(&saved);
 }
 
 void
-glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
+__applegl_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
 {
    struct apple_xgl_saved_state saved;
 
    SetRead(&saved);
 
-   __gl_api.CopyPixels(x, y, width, height, type);
+   __ogl_framework_api->CopyPixels(x, y, width, height, type);
 
    UnsetRead(&saved);
 }
 
 void
-glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
+__applegl_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y,
                  GLsizei width)
 {
    struct apple_xgl_saved_state saved;
 
    SetRead(&saved);
 
-   __gl_api.CopyColorTable(target, internalformat, x, y, width);
+   __ogl_framework_api->CopyColorTable(target, internalformat, x, y, width);
 
    UnsetRead(&saved);
 }