Re: gtk-hp-patches
- From: Darin Adler <darin eazel com>
- To: Havoc Pennington <hp redhat com>, <gtk-devel-list gnome org>
- Subject: Re: gtk-hp-patches
- Date: Fri, 14 Jul 2000 16:25:40 -0700
on 7/14/00 4:12 PM, Havoc Pennington at hp@redhat.com wrote:
> The full diff of what I have in my branch is here:
> http://people.redhat.com/~hp/gtk-hp-patch.txt
I was just taking a quick look at the patch and spotted this function.
+int
+read_int (const guchar **p)
+{
+ guint32 num;
+
+ num = g_ntohl (* (guint32*) *p);
+
+ *p += 4;
+
+ return num;
+}
The above won't work on architectures that don't support unaligned reads.
You should instead do this a byte at a time (and you won't need to call
g_ntohl either). Same goes for your output_int function.
You may be using these only with 4-byte-aligned pointers at the moment, but
since they take guchar * pointer parameters, it's much safer to do it a way
that will work unaligned.
You could perhaps look at the bonobo_ui_handler_pixmap_pixbuf_flatten and
bonobo_ui_handler_pixmap_pixbuf_unflatten function and the read_four_bytes
and write_four_bytes helper functions in bonobo/bonobo/bonobo-ui-handler.c.
It would be nice for the GNOME 2.0 version of bonobo to share code with your
inline image routines, and this is only possible if the formats match (which
they currently don't).
Also, if int is larger than 32 bits, your read_int doesn't sign extend the
int, so it works only for non-negative integers on such platforms. The
bonobo read_four_bytes routine has the same problem.
-- Darin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]