mesa: Fix core GL genned-name handling for glBeginQuery().
[mesa.git] / src / mesa / main / errors.c
index 69dbb65cf4037f26a05a96183347e167b3894549..796b6beff7cc21361988adc4c30b099cde254cc9 100644 (file)
@@ -322,7 +322,7 @@ _mesa_log_msg(struct gl_context *ctx, GLenum source, GLenum type,
 
    assert(!emptySlot->message && !emptySlot->length);
 
-   emptySlot->message = MALLOC(len+1);
+   emptySlot->message = malloc(len+1);
    if (emptySlot->message) {
       (void) strncpy(emptySlot->message, buf, (size_t)len);
       emptySlot->message[len] = '\0';
@@ -391,7 +391,7 @@ _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
    }
 
    if (msg->message != (char*)out_of_memory)
-      FREE(msg->message);
+      free(msg->message);
    msg->message = NULL;
    msg->length = 0;
 
@@ -718,11 +718,11 @@ _mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity,
 }
 
 static void GLAPIENTRY
-_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, GLvoid *userParam)
+_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const GLvoid *userParam)
 {
    GET_CURRENT_CONTEXT(ctx);
    ctx->Debug.Callback = callback;
-   ctx->Debug.CallbackData = userParam;
+   ctx->Debug.CallbackData = (void *) userParam;
 }
 
 void
@@ -786,7 +786,7 @@ _mesa_free_errors_data(struct gl_context *ctx)
 
             foreach_s(node, tmp, &ClientIDs->Namespaces[s][t].Severity[sev]) {
                entry = (struct gl_client_severity *)node;
-               FREE(entry);
+               free(entry);
             }
          }
       }
@@ -801,12 +801,21 @@ output_if_debug(const char *prefixString, const char *outputString,
                 GLboolean newline)
 {
    static int debug = -1;
+   static FILE *fout = NULL;
 
    /* Init the local 'debug' var once.
     * Note: the _mesa_init_debug() function should have been called
     * by now so MESA_DEBUG_FLAGS will be initialized.
     */
    if (debug == -1) {
+      /* If MESA_LOG_FILE env var is set, log Mesa errors, warnings,
+       * etc to the named file.  Otherwise, output to stderr.
+       */
+      const char *logFile = _mesa_getenv("MESA_LOG_FILE");
+      if (logFile)
+         fout = fopen(logFile, "w");
+      if (!fout)
+         fout = stderr;
 #ifdef DEBUG
       /* in debug builds, print messages unless MESA_DEBUG="silent" */
       if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
@@ -821,9 +830,10 @@ output_if_debug(const char *prefixString, const char *outputString,
 
    /* Now only print the string if we're required to do so. */
    if (debug) {
-      fprintf(stderr, "%s: %s", prefixString, outputString);
+      fprintf(fout, "%s: %s", prefixString, outputString);
       if (newline)
-         fprintf(stderr, "\n");
+         fprintf(fout, "\n");
+      fflush(fout);
 
 #if defined(_WIN32) && !defined(_WIN32_WCE)
       /* stderr from windows applications without console is not usually