From 4b46f6fe26440aa248c2a4902d8e939bfdd3d31c Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Mon, 27 Dec 2010 01:21:46 +0000 Subject: [PATCH] ext_io plugin handlers should be static. --- ChangeLog | 4 ++++ zzip/file.c | 3 +++ zzip/plugin.c | 6 +++++- zzip/plugin.h | 7 +++++-- zzip/zip.c | 2 ++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25274cd..8942d2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-12-27 guidod + * add hints that the ext_io plugin handlers should be static. + 2010-05-09 guidod * zzip/__fnmatch.h: add include to make mingw32 happy. @@ -12,6 +15,7 @@ * Makefile.am: fix "osc rm" and fix "test-sdl" if SDL was not found. * configure.ac: SDL example builds on pkgconfig/sdl.pc which + was introduced with SDL 1.2.11 - CentOs5 ships 1.2.10 which does only have "sdl-config" and it made for a mismatch in in the build configuration: sdl-devel yes, pkgconfig sdl no. diff --git a/zzip/file.c b/zzip/file.c index 37d72ed..83a71f3 100644 --- a/zzip/file.c +++ b/zzip/file.c @@ -717,6 +717,9 @@ zzip_open(zzip_char_t * filename, int o_flags) * * This function returns a new zzip-handle (use => zzip_close to return * it). On error this function will return null setting => errno(3). + * + * If any ext_io handlers were used then the referenced structure + * should be static as the allocated ZZIP_FILE does not copy them. */ ZZIP_FILE * zzip_open_ext_io(zzip_char_t * filename, int o_flags, int o_modes, diff --git a/zzip/plugin.c b/zzip/plugin.c index a7d77c0..ee578f4 100644 --- a/zzip/plugin.c +++ b/zzip/plugin.c @@ -55,7 +55,8 @@ static const struct zzip_plugin_io default_io = { /** => zzip_init_io * This function returns a zzip_plugin_io_t handle to static defaults - * wrapping the posix io file functions for actual file access. + * wrapping the posix io file functions for actual file access. The + * returned structure is shared by all threads in the system. */ zzip_plugin_io_t zzip_get_default_io(void) @@ -66,6 +67,9 @@ zzip_get_default_io(void) /** * This function initializes the users handler struct to default values * being the posix io functions in default configured environments. + * + * Note that the target io_handlers_t structure should be static or + * atleast it should be kept during the lifetime of zzip operations. */ int zzip_init_io(zzip_plugin_io_handlers_t io, int flags) diff --git a/zzip/plugin.h b/zzip/plugin.h index b6ccbe8..8282193 100644 --- a/zzip/plugin.h +++ b/zzip/plugin.h @@ -59,7 +59,8 @@ typedef union _zzip_plugin_io } zzip_plugin_io_handlers; #define _zzip_plugin_io_handlers zzip_plugin_io_handlers -/* for backward compatibility, and the following to your application code: + +/* for backward compatibility, add the following to your application code: * #ifndef _zzip_plugin_io_handlers * #define _zzip_plugin_io_handlers struct zzip_plugin_io */ @@ -74,7 +75,9 @@ typedef zzip_plugin_io_handlers* zzip_plugin_io_handlers_t; _zzip_export zzip_off_t zzip_filesize(int fd); -/* get the default file I/O functions */ +/* get the default file I/O functions. + * This functions returns a pointer to an internal static structure. + */ _zzip_export zzip_plugin_io_t zzip_get_default_io(void); /* diff --git a/zzip/zip.c b/zzip/zip.c index 47a211a..f2d89c3 100644 --- a/zzip/zip.c +++ b/zzip/zip.c @@ -797,6 +797,8 @@ zzip_dir_open(zzip_char_t * filename, zzip_error_t * e) /** => zzip_dir_open * this function uses explicit ext and io instead of the internal * defaults. Setting these to zero is equivalent to => zzip_dir_open + * Note that the referenced ext_io plugin handlers structure must be + * static as it is not copied to the returned ZZIP_DIR structure. */ ZZIP_DIR * zzip_dir_open_ext_io(zzip_char_t * filename, zzip_error_t * e, -- 2.40.0