Receiving multiple lines with g_io_channel_read_line

2005-02-07 Thread Andrew Gatt
Hi,

I've had some sucess using g_io_channel_read_line to
receive terminated lines from a fifo formed with a
server app i wrote. However i need to receive unknown
amounts of bytes with line terminators until a final
escape character is received, then act on this packet.
Is this possible to do in one callback, or should i be
using multiple callbacks and a global gchar to buffer
until the escape character - or would it be better to
somehow use g_io_channel_read? I've seen a previous
post about receiving the characters one at a time,
which i could use - but i couldn't get it to work
properly and didn't think this would be too efficient.

Any ideas?
Thanks
Andrew

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Memory allocation in Windows error

2005-02-07 Thread Tor Lillqvist
edward hage writes:
  I wrote a GTK-application in Linux and it works fine.

That might just be a coincidence, it might *seem* to work fine, with
some input data. Have you run it under valgrind on Linux?

Or, download an evaluation copy of Purify or BoundsChecker for Windows
and run it under that. (Hmm, except that those tools work well only if
you build with MSVC, so this probably is not useful.)

  I get this error mainly when I am loading a file from disk.

That could be just coincidental, the actual dynamic memory handling
error (overflowing a malloced block, use of freed memory, freeing an
already freed pointer, etc) might have happened much earlier, and the
crash then happens at some random later point. This is typical for
dynamic memory handling errors (also on Unix).

  because I don't use malloc, correct ?

But do you use any of the GLib memory handling functions, like
g_malloc(), g_new(), g_free()?

--tml


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Memory allocation in Windows error

2005-02-07 Thread edward hage

Tor Lillqvist wrote:
edward hage writes:
  I wrote a GTK-application in Linux and it works fine.
That might just be a coincidence, it might *seem* to work fine, with
some input data. Have you run it under valgrind on Linux?
I never tried valgrind, I have it on my computer so just used it.
I don't understand all the lingo it outputs on the screen, but the moment I pushed the 
okay button for loading a file indeed more than 30,000 errors, so valgrind just stopped 
with its output. Okay, I can't blame the program.

It's output:
==22808== Conditional jump or move depends on uninitialised value(s)
==22808==at 0x806110D: DetermineSetpointXandV (generate_setpoint.c:295)
==22808==by 0x80507F2: Create_profiles (calculate.c:753)
==22808==by 0x8051068: Calculate_moves_and_forces (calculate.c:850)
==22808==by 0x80546F7: toolbar_start_calculate (menus.c:471)
==22808==
==22808== Invalid write of size 1
==22808==at 0x8064819: Load_data_from_file (loadcase.c:222)
==22808==by 0x8064C2A: fileopen_callback (loadcase.c:135)
==22808==by 0x406457C0: g_cclosure_marshal_VOID__VOID (gmarshal.c:77)
==22808==by 0x40636DAA: g_closure_invoke (gclosure.c:437)
==22808==Address 0x424A4168 is 0 bytes after a block of size 4 alloc'd
==22808==at 0x40027CB4: malloc (in /usr/lib/valgrind/vgskin_memcheck.so)
==22808==by 0x4069B0B6: g_malloc (gmem.c:136)
==22808==by 0x8064649: Load_data_from_file (loadcase.c:173)
==22808==by 0x8064C2A: fileopen_callback (loadcase.c:135)
==22808==
==22808== Invalid read of size 1
==22808==at 0x40720AD0: __GI_strtod_l_internal (in /lib/libc.so.6)
==22808==by 0x4071D860: __GI___strtod_internal (in /lib/libc.so.6)
==22808==by 0x80649D1: Load_data_from_file (stdlib.h:311)
==22808==by 0x8064C2A: fileopen_callback (loadcase.c:135)
==22808==Address 0x424A4168 is 0 bytes after a block of size 4 alloc'd
==22808==at 0x40027CB4: malloc (in /usr/lib/valgrind/vgskin_memcheck.so)
==22808==by 0x4069B0B6: g_malloc (gmem.c:136)
==22808==by 0x8064649: Load_data_from_file (loadcase.c:173)
==22808==by 0x8064C2A: fileopen_callback (loadcase.c:135)
The Invalid read of size 1 occures 3 times.I try to find out what happens 
here.
I will try to find on the web where I can find a clear tutorial of valgrind (no manpage is 
supplied). If anybody has suggestions for a tutorial I am interested !!


  because I don't use malloc, correct ?
But do you use any of the GLib memory handling functions, like
g_malloc(), g_new(), g_free()?
Yes, I use g_malloc for almost every pointer and GArray I define. Also in the function in 
which I read the file. I know I don't consequently have a g_free for every g_malloc, but I 
didn't experience any problems with it (or better: I didn't realise the problems I have 
with it).

Thank you for the info.
Edward
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Compile Line for GnomeVFS Programs.

2005-02-07 Thread Allin Cottrell
On Mon, 7 Feb 2005, Tony Freeman wrote:
Every time I try to compile a program that has a #include gnome.h I
run into problems.  For example:  I have just finished typing in the
sample program located at:
http://developer.gnome.org/doc/API/2.0/gnome-vfs-2.0/gnome-vfs-first-steps.html
Now I want to compile.  I finally got the program to compile with this
line:
gcc `pkg-config --cflags --libs gnome libgnomevfs` gnome-vfs.c -o test
Try
pkg-config --cflags --libs gnome gnome-vfs-2.0
If this doesn't work, then you don't have the right files installed.
Allin Cottrell
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list