]> git.cworth.org Git - grrobot/blobdiff - src/grr_board_view.c
Fixed messages and scrolling
[grrobot] / src / grr_board_view.c
index c4cf316e49103c9c158bd5373c9fc237206f9f3b..4a3b733713627e586b731617d873204bbe0615da 100644 (file)
@@ -28,7 +28,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdarg.h>
 
 #include <Xr.h>
 #include <xsvg.h>
@@ -38,6 +37,7 @@
 #include <gdk/gdkx.h>
 
 #include "grr_board_view.h"
+#include "grr_util.h"
 
 #define SCROLL_DELAY_LENGTH  300
 #define GRR_BOARD_VIEW_DEFAULT_SIZE 100
 
 /* Forward declarations */
 
-static int
-grr_sprintf_alloc (char **str, const char *fmt, ...);
-
-static int
-grr_sprintf_alloc_va (char **str, const char *fmt, va_list ap);
-
-
 static void grr_board_view_class_init               (grr_board_view_class_t    *klass);
 static void grr_board_view_init                     (grr_board_view_t         *view);
 static void grr_board_view_destroy                  (GtkObject        *object);
@@ -761,46 +754,3 @@ grr_board_view_update (grr_board_view_t *view)
     gtk_widget_queue_draw (GTK_WIDGET (view));
 }
 
-static int
-grr_sprintf_alloc (char **str, const char *fmt, ...)
-{
-    int ret;
-    va_list ap;
-
-    va_start(ap, fmt);
-    ret = grr_sprintf_alloc_va (str, fmt, ap);
-    va_end(ap);
-
-    return ret;
-}
-
-/* ripped more or less straight out of PRINTF(3) */
-static int
-grr_sprintf_alloc_va (char **str, const char *fmt, va_list ap)
-{
-    char *new_str;
-    /* Guess we need no more than 100 bytes. */
-    int n, size = 100;
-    if ((*str = malloc (size)) == NULL)
-       return -1;
-    while (1) {
-       /* Try to print in the allocated space. */
-       n = vsnprintf (*str, size, fmt, ap);
-       /* If that worked, return the size. */
-       if (n > -1 && n < size)
-           return n;
-       /* Else try again with more space. */
-       if (n > -1)    /* glibc 2.1 */
-           size = n+1; /* precisely what is needed */
-       else           /* glibc 2.0 */
-           size *= 2;  /* twice the old size */
-       new_str = realloc(*str, size);
-       if (new_str == NULL) {
-           free(*str);
-           *str = NULL;
-           return -1;
-       }
-       *str = new_str;
-    }
-}