postprocess: Portability fixes.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 25 Sep 2011 10:56:12 +0000 (11:56 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 25 Sep 2011 11:18:55 +0000 (12:18 +0100)
src/gallium/auxiliary/postprocess/pp_init.c
src/gallium/auxiliary/postprocess/pp_mlaa.c
src/gallium/auxiliary/postprocess/pp_program.c

index 75417999b7e2a03fcdcef9f96bc9b10099f4d95d..fd9eb22dc0696451fa65d7b2d68bdda63ebd78df 100644 (file)
@@ -25,9 +25,7 @@
  *
  **************************************************************************/
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
+#include "pipe/p_compiler.h"
 
 #include "postprocess/filters.h"
 
@@ -35,6 +33,8 @@
 #include "util/u_inlines.h"
 #include "util/u_blit.h"
 #include "util/u_math.h"
+#include "util/u_debug.h"
+#include "util/u_memory.h"
 #include "cso_cache/cso_context.h"
 
 /** Initialize the post-processing queue. */
@@ -56,10 +56,10 @@ pp_init(struct pipe_screen *pscreen, const unsigned int *enabled)
    if (!curpos)
       return NULL;
 
-   ppq = calloc(1, sizeof(struct pp_queue_t));
-   tmp_q = calloc(curpos, sizeof(pp_func));
-   ppq->shaders = calloc(curpos, sizeof(void *));
-   ppq->verts = calloc(curpos, sizeof(unsigned int));
+   ppq = CALLOC(1, sizeof(struct pp_queue_t));
+   tmp_q = CALLOC(curpos, sizeof(pp_func));
+   ppq->shaders = CALLOC(curpos, sizeof(void *));
+   ppq->verts = CALLOC(curpos, sizeof(unsigned int));
 
    if (!tmp_q || !ppq || !ppq->shaders || !ppq->verts)
       goto error;
@@ -78,7 +78,7 @@ pp_init(struct pipe_screen *pscreen, const unsigned int *enabled)
 
          if (pp_filters[i].shaders) {
             ppq->shaders[curpos] =
-               calloc(pp_filters[i].shaders + 1, sizeof(void *));
+               CALLOC(pp_filters[i].shaders + 1, sizeof(void *));
             ppq->verts[curpos] = pp_filters[i].verts;
             if (!ppq->shaders[curpos])
                goto error;
@@ -110,9 +110,9 @@ pp_init(struct pipe_screen *pscreen, const unsigned int *enabled)
    pp_debug("Error setting up pp\n");
 
    if (ppq)
-      free(ppq->p);
-   free(ppq);
-   free(tmp_q);
+      FREE(ppq->p);
+   FREE(ppq);
+   FREE(tmp_q);
 
    return NULL;
 }
@@ -171,9 +171,9 @@ pp_free(struct pp_queue_t *ppq)
    cso_destroy_context(ppq->p->cso);
    ppq->p->pipe->destroy(ppq->p->pipe);
 
-   free(ppq->p);
-   free(ppq->pp_queue);
-   free(ppq);
+   FREE(ppq->p);
+   FREE(ppq->pp_queue);
+   FREE(ppq);
 
    pp_debug("Queue taken down.\n");
 }
@@ -184,11 +184,11 @@ pp_debug(const char *fmt, ...)
 {
    va_list ap;
 
-   if (!getenv("PP_DEBUG"))
+   if (!debug_get_bool_option("PP_DEBUG", FALSE))
       return;
 
    va_start(ap, fmt);
-   vfprintf(stderr, fmt, ap);
+   _debug_vprintf(fmt, ap);
    va_end(ap);
 }
 
index 5708687a1c2d44313e06fe300af4427e92adf8b9..f514e692985702dc7b04be18b13d67067afa9bb9 100644 (file)
@@ -38,8 +38,8 @@
  * policies, either expressed or implied, of the copyright holders.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include "pipe/p_compiler.h"
+
 #include "postprocess/postprocess.h"
 #include "postprocess/pp_mlaa.h"
 #include "postprocess/pp_filters.h"
@@ -47,6 +47,8 @@
 #include "util/u_box.h"
 #include "util/u_sampler.h"
 #include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_string.h"
 #include "pipe/p_screen.h"
 
 #define IMM_SPACE 80
@@ -211,7 +213,7 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
    struct pipe_box box;
    struct pipe_resource res;
 
-   char *tmp_text = calloc(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
+   char *tmp_text = CALLOC(sizeof(blend2fs_1) + sizeof(blend2fs_2) +
                            IMM_SPACE, sizeof(char));
 
    constbuf = pipe_buffer_create(ppq->p->screen, PIPE_BIND_CONSTANT_BUFFER,
@@ -228,9 +230,9 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
       pp_debug("Failed to allocate shader space\n");
       return;
    }
-   sprintf(tmp_text, "%s"
-           "IMM FLT32 {    %.8f,     0.0000,     0.0000,     0.0000}\n"
-           "%s\n", blend2fs_1, (float) val, blend2fs_2);
+   util_sprintf(tmp_text, "%s"
+                "IMM FLT32 {    %.8f,     0.0000,     0.0000,     0.0000}\n"
+                "%s\n", blend2fs_1, (float) val, blend2fs_2);
 
    memset(&res, 0, sizeof(res));
 
@@ -267,7 +269,7 @@ pp_jimenezmlaa_init_run(struct pp_queue_t *ppq, unsigned int n,
    ppq->shaders[n][4] = pp_tgsi_to_state(ppq->p->pipe, neigh3fs, false,
                                          "neigh3fs");
 
-   free(tmp_text);
+   FREE(tmp_text);
 }
 
 /** Short wrapper to init the depth version. */
index b92ac80a5dbd236b63fe8a29cb9aef96933477cb..c287af5cf0033bd75cc9d0c0fc5d0c863f0199eb 100644 (file)
 #include "pipe/p_shader_tokens.h"
 #include "util/u_inlines.h"
 #include "util/u_simple_shaders.h"
+#include "util/u_memory.h"
 
 /** Initialize the internal details */
 struct program *
 pp_init_prog(struct pp_queue_t *ppq, struct pipe_screen *pscreen)
 {
 
-   struct program *p = calloc(1, sizeof(struct program));
+   struct program *p = CALLOC(1, sizeof(struct program));
 
    pp_debug("Initializing program\n");
    if (!pscreen)