off_t in libgsf interface is problematic



Hi,

I think we should change the off_t parameters in the exported libgsf
interface to gint64 (gsf_input_seek, gsf_output_seek).

The reason is that we don't know how large the user of the library
believes the size of off_t is.

On Linux/i386/GNU libc, the size is 32 bits by default. But this is
changed to 64 bits if #define _FILE_OFFSET_BITS 64 occurs somewhere in
the header files.

This put me into trouble when working with the Python bindings for
libgsf. The Python API defines off_t to 64 bits, libgsf uses 32, so
bad things happen when trying to pass parameters which included off_t.

I think the solution chosen in glib for g_io_channels looks
reasonable. E.g:

GIOError  g_io_channel_seek     (GIOChannel    *channel,
                                 gint64         offset, 
                                 GSeekType      type);

The implementation uses off_t - 64 bits if available - and checks for
overflow.

What do you think?

Jon Kåre






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]