mesa: make _mesa_reference_shader_program() an inline function
authorBrian Paul <brianp@vmware.com>
Fri, 2 Jan 2015 23:56:12 +0000 (16:56 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 5 Jan 2015 20:50:54 +0000 (13:50 -0700)
which wraps _mesa_reference_shader_program_(), similar to what we do
for other reference-counted objects.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/shaderobj.c
src/mesa/main/shaderobj.h

index 81bd7829d36c0b9cfa7d86a699f85f6d16456d7d..02ccf450bf9cc0e5204eebb5a4acf09ba7320c43 100644 (file)
@@ -193,9 +193,9 @@ _mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller)
  * Then set ptr to point to shProg, incrementing its refcount.
  */
 void
-_mesa_reference_shader_program(struct gl_context *ctx,
-                               struct gl_shader_program **ptr,
-                               struct gl_shader_program *shProg)
+_mesa_reference_shader_program_(struct gl_context *ctx,
+                                struct gl_shader_program **ptr,
+                                struct gl_shader_program *shProg)
 {
    assert(ptr);
    if (*ptr == shProg) {
index 05ddfeb50f17920a586c9bf7b3a153605937696b..92f7a33eec2fc7e9156d0ae017a19797dc88815e 100644 (file)
@@ -62,9 +62,20 @@ _mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller)
 
 
 extern void
-_mesa_reference_shader_program(struct gl_context *ctx,
+_mesa_reference_shader_program_(struct gl_context *ctx,
                                struct gl_shader_program **ptr,
                                struct gl_shader_program *shProg);
+
+static inline void
+_mesa_reference_shader_program(struct gl_context *ctx,
+                               struct gl_shader_program **ptr,
+                               struct gl_shader_program *shProg)
+{
+   if (*ptr != shProg)
+      _mesa_reference_shader_program_(ctx, ptr, shProg);
+}
+
+
 extern void
 _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader);