RE: [gtk-list] segfault problem
- From: tile primenet com
- To: gtk-list redhat com
- Subject: RE: [gtk-list] segfault problem
- Date: Tue, 14 Apr 1998 21:29:47 -0000 (???)
Here's a patch...
In short, you forgot to malloc filedata and left a couple things unused. I ran
it through -ansi -pedantic -Wall.
--
tile
tile@primenet.com
--- segg1.c Tue Apr 14 21:24:51 1998
+++ segg.c Tue Apr 14 21:26:39 1998
@@ -1,6 +1,8 @@
/* This file was modified from a file extracted from the GTK tutorial. */
/* list.c */
+#define _POSIX_SOURCE
+
#include <gtk/gtk.h>
#include <stdio.h>
#include <unistd.h>
@@ -10,11 +12,11 @@
void addtolist (gpointer data, gint source, GdkInputCondition condition)
{
- static int i = 1;
+ /* static int i = 1; */
gchar buffer[64];
GtkWidget *list_item;
- GtkWidget *list;
- char *filedata;
+ /* GtkWidget *list; */
+ char *filedata = (char *)malloc (2047);
if (fgets(filedata, 2047, pfile)!=NULL) {
printf("Error in file");
@@ -33,11 +35,11 @@
GtkWidget *vbox;
GtkWidget *scrolled_window;
GtkWidget *button;
- GtkWidget *list_item;
+ /* GtkWidget *list_item; */
GtkWidget *gtklist;
GList *dlist;
- gchar buffer[64];
- guint i;
+ /* gchar buffer[64]; */
+ /* guint i; */
/* static int listtimer = 0; */
gint infile;
@@ -102,7 +104,7 @@
if (pfile == NULL)
{
printf("Error opening file!");
- return;
+ return 1;
}
infile = gdk_input_add (fileno(pfile), GDK_INPUT_READ, addtolist, gtklist);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]