On Sat, Mar 7, 2015 at 1:13 PM, Brian Paul <brian.e.p...@gmail.com> wrote:

> On Sat, Mar 7, 2015 at 12:38 PM, Emil Velikov <emil.l.veli...@gmail.com>
> wrote:
>
>
>> FYI I'm contemplating on about adding a final wrapper - c99_string.h. It
>> should nuke nearly all of the remaining compiler abstraction that we
>> have around - mapi, egl, gallium, mesa, glsl...
>>
>
> Yeah, I was looking at doing something like that for stroll() and
> strcasecmp().  I already have a patch series which removes _mesa_strdup()
> and another that moves fpclassify() to c99_math.h
>
> I'm on the road ATM and can't test the Windows build but I guess I could
> post my patches now.  I can test on Windows in a few days.
>

Hmm, git send-email isn't cooperating with my gmail account right now.  I'm
just attaching the patches for now.

-Brian
From 90cc53e67e076fe7a38ae7ac3943868258c820ae Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 1/7] mesa: move fpclassify work-arounds into c99_math.h

---
 include/c99_math.h          | 52 +++++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/querymatrix.c | 51 +-------------------------------------------
 2 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/include/c99_math.h b/include/c99_math.h
index 0a49950..f1a6685 100644
--- a/include/c99_math.h
+++ b/include/c99_math.h
@@ -161,4 +161,56 @@ llrintf(float f)
 #endif
 
 
+#if defined(fpclassify)
+/* ISO C99 says that fpclassify is a macro.  Assume that any implementation
+ * of fpclassify, whether it's in a C99 compiler or not, will be a macro.
+ */
+#elif defined(__cplusplus)
+/* For C++, fpclassify() should be defined in <cmath> */
+#elif defined(_MSC_VER)
+/* Not required on VS2013 and above.  Oddly, the fpclassify() function
+ * doesn't exist in such a form on MSVC.  This is an implementation using
+ * slightly different lower-level Windows functions.
+ */
+#include <float.h>
+
+static inline enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
+fpclassify(double x)
+{
+   switch(_fpclass(x)) {
+   case _FPCLASS_SNAN: /* signaling NaN */
+   case _FPCLASS_QNAN: /* quiet NaN */
+      return FP_NAN;
+   case _FPCLASS_NINF: /* negative infinity */
+   case _FPCLASS_PINF: /* positive infinity */
+      return FP_INFINITE;
+   case _FPCLASS_NN:   /* negative normal */
+   case _FPCLASS_PN:   /* positive normal */
+      return FP_NORMAL;
+   case _FPCLASS_ND:   /* negative denormalized */
+   case _FPCLASS_PD:   /* positive denormalized */
+      return FP_SUBNORMAL;
+   case _FPCLASS_NZ:   /* negative zero */
+   case _FPCLASS_PZ:   /* positive zero */
+      return FP_ZERO;
+   default:
+      /* Should never get here; but if we do, this will guarantee
+       * that the pattern is not treated like a number.
+       */
+      return FP_NAN;
+   }
+}
+
+#else
+
+static inline enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
+fpclassify(double x)
+{
+   /* XXX do something better someday */
+   return FP_NORMAL;
+}
+
+#endif
+
+
 #endif /* #define _C99_MATH_H_ */
diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index ef85175..095817c 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -13,7 +13,7 @@
 
 
 #include <stdlib.h>
-#include <math.h>
+#include "c99_math.h"
 #include "glheader.h"
 #include "querymatrix.h"
 #include "main/get.h"
@@ -37,55 +37,6 @@
 #define INT_TO_FIXED(x) ((GLfixed) ((x) << 16))
 #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))
 
-#if defined(fpclassify)
-/* ISO C99 says that fpclassify is a macro.  Assume that any implementation
- * of fpclassify, whether it's in a C99 compiler or not, will be a macro.
- */
-#elif defined(_MSC_VER)
-/* Not required on VS2013 and above. */
-/* Oddly, the fpclassify() function doesn't exist in such a form
- * on MSVC.  This is an implementation using slightly different
- * lower-level Windows functions.
- */
-#include <float.h>
-
-enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
-fpclassify(double x)
-{
-    switch(_fpclass(x)) {
-        case _FPCLASS_SNAN: /* signaling NaN */
-        case _FPCLASS_QNAN: /* quiet NaN */
-            return FP_NAN;
-        case _FPCLASS_NINF: /* negative infinity */
-        case _FPCLASS_PINF: /* positive infinity */
-            return FP_INFINITE;
-        case _FPCLASS_NN:   /* negative normal */
-        case _FPCLASS_PN:   /* positive normal */
-            return FP_NORMAL;
-        case _FPCLASS_ND:   /* negative denormalized */
-        case _FPCLASS_PD:   /* positive denormalized */
-            return FP_SUBNORMAL;
-        case _FPCLASS_NZ:   /* negative zero */
-        case _FPCLASS_PZ:   /* positive zero */
-            return FP_ZERO;
-        default:
-            /* Should never get here; but if we do, this will guarantee
-             * that the pattern is not treated like a number.
-             */
-            return FP_NAN;
-    }
-}
-
-#else
-
-enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
-fpclassify(double x)
-{
-   /* XXX do something better someday */
-   return FP_NORMAL;
-}
-
-#endif
 
 GLbitfield GLAPIENTRY _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
 {
-- 
1.9.1

From f587cfc4ede4600f012e162204b5f886342b7ac3 Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 2/7] mesa: reindent querymatrix.c

Use 3-space indents, not 4.  Move some comments after the case statements.
---
 src/mesa/main/querymatrix.c | 229 ++++++++++++++++++++++----------------------
 1 file changed, 115 insertions(+), 114 deletions(-)

diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index 095817c..ca6b023 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -38,119 +38,120 @@
 #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))
 
 
-GLbitfield GLAPIENTRY _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
+GLbitfield GLAPIENTRY
+_mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
 {
-    GLfloat matrix[16];
-    GLint tmp;
-    GLenum currentMode = GL_FALSE;
-    GLenum desiredMatrix = GL_FALSE;
-    /* The bitfield returns 1 for each component that is invalid (i.e.
-     * NaN or Inf).  In case of error, everything is invalid.
-     */
-    GLbitfield rv;
-    register unsigned int i;
-    unsigned int bit;
-
-    /* This data structure defines the mapping between the current matrix
-     * mode and the desired matrix identifier.
-     */
-    static struct {
-        GLenum currentMode;
-        GLenum desiredMatrix;
-    } modes[] = {
-        {GL_MODELVIEW, GL_MODELVIEW_MATRIX},
-        {GL_PROJECTION, GL_PROJECTION_MATRIX},
-        {GL_TEXTURE, GL_TEXTURE_MATRIX},
-    };
-
-    /* Call Mesa to get the current matrix in floating-point form.  First,
-     * we have to figure out what the current matrix mode is.
-     */
-    _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp);
-    currentMode = (GLenum) tmp;
-
-    /* The mode is either GL_FALSE, if for some reason we failed to query
-     * the mode, or a given mode from the above table.  Search for the
-     * returned mode to get the desired matrix; if we don't find it,
-     * we can return immediately, as _mesa_GetInteger() will have
-     * logged the necessary error already.
-     */
-    for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) {
-        if (modes[i].currentMode == currentMode) {
-            desiredMatrix = modes[i].desiredMatrix;
-            break;
-        }
-    }
-    if (desiredMatrix == GL_FALSE) {
-        /* Early error means all values are invalid. */
-        return 0xffff;
-    }
-
-    /* Now pull the matrix itself. */
-    _mesa_GetFloatv(desiredMatrix, matrix);
-
-    rv = 0;
-    for (i = 0, bit = 1; i < 16; i++, bit<<=1) {
-        float normalizedFraction;
-        int exp;
-
-        switch (fpclassify(matrix[i])) {
-            /* A "subnormal" or denormalized number is too small to be
-             * represented in normal format; but despite that it's a
-             * valid floating point number.  FP_ZERO and FP_NORMAL
-             * are both valid as well.  We should be fine treating
-             * these three cases as legitimate floating-point numbers.
-             */
-            case FP_SUBNORMAL:
-            case FP_NORMAL:
-            case FP_ZERO:
-                normalizedFraction = (GLfloat)frexp(matrix[i], &exp);
-                mantissa[i] = FLOAT_TO_FIXED(normalizedFraction);
-                exponent[i] = (GLint) exp;
-                break;
-
-            /* If the entry is not-a-number or an infinity, then the
-             * matrix component is invalid.  The invalid flag for
-             * the component is already set; might as well set the
-             * other return values to known values.  We'll set
-             * distinct values so that a savvy end user could determine
-             * whether the matrix component was a NaN or an infinity,
-             * but this is more useful for debugging than anything else
-             * since the standard doesn't specify any such magic
-             * values to return.
-             */
-            case FP_NAN:
-                mantissa[i] = INT_TO_FIXED(0);
-                exponent[i] = (GLint) 0;
-                rv |= bit;
-                break;
-
-            case FP_INFINITE:
-                /* Return +/- 1 based on whether it's a positive or
-                 * negative infinity.
-                 */
-                if (matrix[i] > 0) {
-                    mantissa[i] = INT_TO_FIXED(1);
-                }
-                else {
-                    mantissa[i] = -INT_TO_FIXED(1);
-                }
-                exponent[i] = (GLint) 0;
-                rv |= bit;
-                break;
-
-            /* We should never get here; but here's a catching case
-             * in case fpclassify() is returnings something unexpected.
-             */
-            default:
-                mantissa[i] = INT_TO_FIXED(2);
-                exponent[i] = (GLint) 0;
-                rv |= bit;
-                break;
-        }
-
-    } /* for each component */
-
-    /* All done */
-    return rv;
+   GLfloat matrix[16];
+   GLint tmp;
+   GLenum currentMode = GL_FALSE;
+   GLenum desiredMatrix = GL_FALSE;
+   /* The bitfield returns 1 for each component that is invalid (i.e.
+    * NaN or Inf).  In case of error, everything is invalid.
+    */
+   GLbitfield rv;
+   register unsigned int i;
+   unsigned int bit;
+
+   /* This data structure defines the mapping between the current matrix
+    * mode and the desired matrix identifier.
+    */
+   static struct {
+      GLenum currentMode;
+      GLenum desiredMatrix;
+   } modes[] = {
+      {GL_MODELVIEW, GL_MODELVIEW_MATRIX},
+      {GL_PROJECTION, GL_PROJECTION_MATRIX},
+      {GL_TEXTURE, GL_TEXTURE_MATRIX},
+   };
+
+   /* Call Mesa to get the current matrix in floating-point form.  First,
+    * we have to figure out what the current matrix mode is.
+    */
+   _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp);
+   currentMode = (GLenum) tmp;
+
+   /* The mode is either GL_FALSE, if for some reason we failed to query
+    * the mode, or a given mode from the above table.  Search for the
+    * returned mode to get the desired matrix; if we don't find it,
+    * we can return immediately, as _mesa_GetInteger() will have
+    * logged the necessary error already.
+    */
+   for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) {
+      if (modes[i].currentMode == currentMode) {
+         desiredMatrix = modes[i].desiredMatrix;
+         break;
+      }
+   }
+   if (desiredMatrix == GL_FALSE) {
+      /* Early error means all values are invalid. */
+      return 0xffff;
+   }
+
+   /* Now pull the matrix itself. */
+   _mesa_GetFloatv(desiredMatrix, matrix);
+
+   rv = 0;
+   for (i = 0, bit = 1; i < 16; i++, bit<<=1) {
+      float normalizedFraction;
+      int exp;
+
+      switch (fpclassify(matrix[i])) {
+      case FP_SUBNORMAL:
+      case FP_NORMAL:
+      case FP_ZERO:
+         /* A "subnormal" or denormalized number is too small to be
+          * represented in normal format; but despite that it's a
+          * valid floating point number.  FP_ZERO and FP_NORMAL
+          * are both valid as well.  We should be fine treating
+          * these three cases as legitimate floating-point numbers.
+          */
+         normalizedFraction = (GLfloat)frexp(matrix[i], &exp);
+         mantissa[i] = FLOAT_TO_FIXED(normalizedFraction);
+         exponent[i] = (GLint) exp;
+         break;
+
+      case FP_NAN:
+         /* If the entry is not-a-number or an infinity, then the
+          * matrix component is invalid.  The invalid flag for
+          * the component is already set; might as well set the
+          * other return values to known values.  We'll set
+          * distinct values so that a savvy end user could determine
+          * whether the matrix component was a NaN or an infinity,
+          * but this is more useful for debugging than anything else
+          * since the standard doesn't specify any such magic
+          * values to return.
+          */
+         mantissa[i] = INT_TO_FIXED(0);
+         exponent[i] = (GLint) 0;
+         rv |= bit;
+         break;
+
+      case FP_INFINITE:
+         /* Return +/- 1 based on whether it's a positive or
+          * negative infinity.
+          */
+         if (matrix[i] > 0) {
+            mantissa[i] = INT_TO_FIXED(1);
+         }
+         else {
+            mantissa[i] = -INT_TO_FIXED(1);
+         }
+         exponent[i] = (GLint) 0;
+         rv |= bit;
+         break;
+
+      default:
+         /* We should never get here; but here's a catching case
+          * in case fpclassify() is returnings something unexpected.
+          */
+         mantissa[i] = INT_TO_FIXED(2);
+         exponent[i] = (GLint) 0;
+         rv |= bit;
+         break;
+      }
+
+   } /* for each component */
+
+   /* All done */
+   return rv;
 }
-- 
1.9.1

From d8c075785754412bba20b446ee44862999eced9e Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 3/7] mesa: remove register keyword, add const in
 _mesa_QueryMatrixxOES()

---
 src/mesa/main/querymatrix.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index ca6b023..ccd5c5e 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -49,13 +49,12 @@ _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
     * NaN or Inf).  In case of error, everything is invalid.
     */
    GLbitfield rv;
-   register unsigned int i;
-   unsigned int bit;
+   unsigned i, bit;
 
    /* This data structure defines the mapping between the current matrix
     * mode and the desired matrix identifier.
     */
-   static struct {
+   static const struct {
       GLenum currentMode;
       GLenum desiredMatrix;
    } modes[] = {
-- 
1.9.1

From a5d2aa9644901761250c808958708d572ff59b61 Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 4/7] mesa: use ARRAY_SIZE in _mesa_QueryMatrixxOES()

---
 src/mesa/main/querymatrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index ccd5c5e..18361c9 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -75,7 +75,7 @@ _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
     * we can return immediately, as _mesa_GetInteger() will have
     * logged the necessary error already.
     */
-   for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) {
+   for (i = 0; i < ARRAY_SIZE(modes); i++) {
       if (modes[i].currentMode == currentMode) {
          desiredMatrix = modes[i].desiredMatrix;
          break;
-- 
1.9.1

From 3726b4e74765a720bfcb4defb07b4c0a13f13f87 Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 5/7] xlib: use strdup() instead of _mesa_strdup()

---
 src/mesa/drivers/x11/fakeglx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 3869e94..4fd6d75 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -40,6 +40,7 @@
  */
 
 
+#include <string.h>
 #include <stdio.h>
 #include "glxheader.h"
 #include "glxapi.h"
@@ -846,7 +847,7 @@ register_with_display(Display *dpy)
       ext = dpy->ext_procs;  /* new extension is at head of list */
       assert(c->extension == ext->codes.extension);
       (void) c; /* silence warning */
-      ext->name = _mesa_strdup(extName);
+      ext->name = strdup(extName);
       ext->close_display = close_display_callback;
    }
 }
-- 
1.9.1

From 5f6c371c79c8d7430a1809566886a7b564b22926 Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 6/7] st/glx: use strdup() instead of _mesa_strdup()

---
 src/gallium/state_trackers/glx/xlib/glx_api.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c
index d1bd760..f9572b7 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -34,6 +34,7 @@
 #include "GL/glx.h"
 
 #include <stdio.h>
+#include <string.h>
 #include <X11/Xmd.h>
 #include <GL/glxproto.h>
 
@@ -644,7 +645,7 @@ register_with_display(Display *dpy)
       ext = dpy->ext_procs;  /* new extension is at head of list */
       assert(c->extension == ext->codes.extension);
       (void) c;
-      ext->name = _mesa_strdup(extName);
+      ext->name = strdup(extName);
       ext->close_display = close_display_callback;
    }
 }
-- 
1.9.1

From ce5a6a2fba3d75ac140773776fb602051fc4525b Mon Sep 17 00:00:00 2001
From: Brian Paul <bri...@vmware.com>
Date: Sat, 7 Mar 2015 13:15:22 -0700
Subject: [PATCH 7/7] mesa: use strdup() instead of _mesa_strdup()

We were already using strdup() in various places in Mesa.  Get rid
of the _mesa_strdup() wrapper.  All the callers pass a non-NULL
argument so the NULL check isn't needed either.
---
 src/mesa/main/imports.c             | 18 ------------------
 src/mesa/main/imports.h             |  3 ---
 src/mesa/main/objectlabel.c         |  2 +-
 src/mesa/main/shaderapi.c           |  2 +-
 src/mesa/main/transformfeedback.c   |  2 +-
 src/mesa/program/prog_instruction.c |  2 +-
 src/mesa/program/prog_parameter.c   |  2 +-
 src/mesa/program/prog_statevars.c   |  2 +-
 src/mesa/program/program.c          |  6 +++---
 9 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index a7ffe22..ac8deeb 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -481,24 +481,6 @@ _mesa_half_to_float(GLhalfARB val)
 /** \name String */
 /*@{*/
 
-/**
- * Implemented using malloc() and strcpy.
- * Note that NULL is handled accordingly.
- */
-char *
-_mesa_strdup( const char *s )
-{
-   if (s) {
-      size_t l = strlen(s);
-      char *s2 = malloc(l + 1);
-      if (s2)
-         strcpy(s2, s);
-      return s2;
-   }
-   else {
-      return NULL;
-   }
-}
 
 /** Compute simple checksum/hash for a string */
 unsigned int
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 7921000..ee6b399 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -448,9 +448,6 @@ _mesa_half_is_negative(GLhalfARB h)
    return h & 0x8000;
 }
 
-extern char *
-_mesa_strdup( const char *s );
-
 extern unsigned int
 _mesa_str_checksum(const char *str);
 
diff --git a/src/mesa/main/objectlabel.c b/src/mesa/main/objectlabel.c
index 78df96b..aecb5b1 100644
--- a/src/mesa/main/objectlabel.c
+++ b/src/mesa/main/objectlabel.c
@@ -76,7 +76,7 @@ set_label(struct gl_context *ctx, char **labelPtr, const char *label,
                 MAX_LABEL_LENGTH);
 
          /* null-terminated string */
-         *labelPtr = _mesa_strdup(label);
+         *labelPtr = strdup(label);
       }
    }
 }
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 5731d58..3ea76af 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1460,7 +1460,7 @@ read_shader(const char *fname)
 
    fclose(f);
 
-   shader = _mesa_strdup(buffer);
+   shader = strdup(buffer);
    free(buffer);
 
    return shader;
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index a3e23ce..ce678c8 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -762,7 +762,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
 
    /* Save the new names and the count */
    for (i = 0; i < count; i++) {
-      shProg->TransformFeedback.VaryingNames[i] = _mesa_strdup(varyings[i]);
+      shProg->TransformFeedback.VaryingNames[i] = strdup(varyings[i]);
    }
    shProg->TransformFeedback.NumVarying = count;
 
diff --git a/src/mesa/program/prog_instruction.c b/src/mesa/program/prog_instruction.c
index 6a9bcb7..f9ebe4e 100644
--- a/src/mesa/program/prog_instruction.c
+++ b/src/mesa/program/prog_instruction.c
@@ -89,7 +89,7 @@ _mesa_copy_instructions(struct prog_instruction *dest,
    memcpy(dest, src, n * sizeof(struct prog_instruction));
    for (i = 0; i < n; i++) {
       if (src[i].Comment)
-         dest[i].Comment = _mesa_strdup(src[i].Comment);
+         dest[i].Comment = strdup(src[i].Comment);
    }
    return dest;
 }
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index 5939f6f..cdfe251 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -148,7 +148,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
 
       for (i = 0; i < sz4; i++) {
          struct gl_program_parameter *p = paramList->Parameters + oldNum + i;
-         p->Name = name ? _mesa_strdup(name) : NULL;
+         p->Name = name ? strdup(name) : NULL;
          p->Type = type;
          p->Size = size;
          p->DataType = datatype;
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index 57b25a7..0c0c87f 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -1045,7 +1045,7 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
       break;
    }
 
-   return _mesa_strdup(str);
+   return strdup(str);
 }
 
 
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 61a9e97..3c214d5 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -79,7 +79,7 @@ _mesa_init_program(struct gl_context *ctx)
    STATIC_ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4));
 
    ctx->Program.ErrorPos = -1;
-   ctx->Program.ErrorString = _mesa_strdup("");
+   ctx->Program.ErrorString = strdup("");
 
    ctx->VertexProgram.Enabled = GL_FALSE;
    ctx->VertexProgram.PointSizeEnabled =
@@ -176,7 +176,7 @@ _mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string)
    free((void *) ctx->Program.ErrorString);
    if (!string)
       string = "";
-   ctx->Program.ErrorString = _mesa_strdup(string);
+   ctx->Program.ErrorString = strdup(string);
 }
 
 
@@ -483,7 +483,7 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog)
    assert(clone->Target == prog->Target);
    assert(clone->RefCount == 1);
 
-   clone->String = (GLubyte *) _mesa_strdup((char *) prog->String);
+   clone->String = (GLubyte *) strdup((char *) prog->String);
    clone->Format = prog->Format;
    clone->Instructions = _mesa_alloc_instructions(prog->NumInstructions);
    if (!clone->Instructions) {
-- 
1.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to