Added _mesa_lookup_program() and _mesa_lookup_bufferobj() functions to avoid
a lot of casting elsewhere.
Use _mesa_lookup_texture() in tdfx driver, use _mesa_lookup_bufferobj() in r300
driver.
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 352ed93..3715003 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -304,6 +304,20 @@
 }
 
 
+/**
+ * Return the gl_program object for a given ID.
+ * Basically just a wrapper for _mesa_HashLookup() to avoid a lot of
+ * casts elsewhere.
+ */
+struct gl_program *
+_mesa_lookup_program(GLcontext *ctx, GLuint id)
+{
+   if (id)
+      return (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+   else
+      return NULL;
+}
+
 
 /**********************************************************************/
 /* Program parameter functions                                        */
@@ -1753,7 +1767,7 @@
    }
    else {
       /* Bind user program */
-      prog = (struct gl_program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+      prog = _mesa_lookup_program(ctx, id);
       if (!prog || prog == &_mesa_DummyProgram) {
          /* allocate a new program now */
          prog = ctx->Driver.NewProgram(ctx, target, id);
@@ -1809,8 +1823,7 @@
 
    for (i = 0; i < n; i++) {
       if (ids[i] != 0) {
-         struct gl_program *prog = (struct gl_program *)
-            _mesa_HashLookup(ctx->Shared->Programs, ids[i]);
+         struct gl_program *prog = _mesa_lookup_program(ctx, ids[i]);
          if (prog == &_mesa_DummyProgram) {
             _mesa_HashRemove(ctx->Shared->Programs, ids[i]);
          }
@@ -1899,7 +1912,7 @@
    if (id == 0)
       return GL_FALSE;
 
-   if (_mesa_HashLookup(ctx->Shared->Programs, id))
+   if (_mesa_lookup_program(ctx, id))
       return GL_TRUE;
    else
       return GL_FALSE;