From 02f2287452b2db6581acf744a1f736b9fb6d0519 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 2 Jul 2008 13:34:52 +0000 Subject: [PATCH] 2008-07-02 15:34 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbziparch/hbziparc.c - removed HB_FUNC_EXIT( HBZIPCLEANUP ) * harbour/contrib/hbziparch/hbzipnew.cpp + added automatic callback destructor registered by hb_vmAtExit() at 1-st callback set --- harbour/ChangeLog | 7 ++++++ harbour/contrib/hbziparch/hbziparc.c | 31 -------------------------- harbour/contrib/hbziparch/hbzipnew.cpp | 18 +++++++++++++-- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 177ea4ea44..da9d75ef46 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-07-02 15:34 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbziparch/hbziparc.c + - removed HB_FUNC_EXIT( HBZIPCLEANUP ) + * harbour/contrib/hbziparch/hbzipnew.cpp + + added automatic callback destructor registered by hb_vmAtExit() + at 1-st callback set + 2008-07-02 14:09 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbtpathy/tpos2.c * moved INCL_* definitions before harbour header files diff --git a/harbour/contrib/hbziparch/hbziparc.c b/harbour/contrib/hbziparch/hbziparc.c index 5cdfe70aad..434da8fd07 100644 --- a/harbour/contrib/hbziparch/hbziparc.c +++ b/harbour/contrib/hbziparch/hbziparc.c @@ -1661,34 +1661,3 @@ HB_FUNC(HB_UNZIPALLFILE) hb_itemRelease( pProgress ); } } - -HB_FUNC_EXIT( HBZIPCLEANUP ) -{ - if( hbza_ChangeDiskBlock ) - { - hb_itemRelease( hbza_ChangeDiskBlock ); - hbza_ChangeDiskBlock = NULL; - } -} -#define __PRG_SOURCE__ (char*) "hbziparc.c" -#ifdef HB_PCODE_VER -# undef HB_PRG_PCODE_VER -# define HB_PRG_PCODE_VER HB_PCODE_VER -#endif - -HB_INIT_SYMBOLS_BEGIN( hbziparch_CLEANUP ) -{ (char*) "HBZIPCLEANUP$", {HB_FS_EXIT | HB_FS_LOCAL}, {HB_EXIT_FUNCNAME( HBZIPCLEANUP )}, NULL } -HB_INIT_SYMBOLS_END( hbziparch_CLEANUP ) - -#if defined(HB_PRAGMA_STARTUP) - #pragma startup hbziparch_CLEANUP -#elif defined(HB_MSC_STARTUP) - #if _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto_SymbolInit_INIT = hbziparch_CLEANUP; - #pragma data_seg() -#endif diff --git a/harbour/contrib/hbziparch/hbzipnew.cpp b/harbour/contrib/hbziparch/hbzipnew.cpp index c47f38e3a0..3692baab28 100644 --- a/harbour/contrib/hbziparch/hbzipnew.cpp +++ b/harbour/contrib/hbziparch/hbzipnew.cpp @@ -619,15 +619,29 @@ int hb___GetNumberofFilestoUnzip( char * szFile ) return iNumberOfFiles; } -int hb___SetCallbackFunc( PHB_ITEM pFunc ) +static void hb___CallbackFuncFree( void * cargo ) { + HB_SYMBOL_UNUSED( cargo ); + if( hbza_ChangeDiskBlock ) { hb_itemRelease( hbza_ChangeDiskBlock ); hbza_ChangeDiskBlock = NULL; } +} - hbza_ChangeDiskBlock = hb_itemNew( NULL ); +int hb___SetCallbackFunc( PHB_ITEM pFunc ) +{ + if( hbza_ChangeDiskBlock ) + { + hb_itemClear( hbza_ChangeDiskBlock ); + } + else + { + /* register cleanup function, it's executed only once */ + hb_vmAtExit( hb___CallbackFuncFree, NULL ); + hbza_ChangeDiskBlock = hb_itemNew( NULL ); + } if( pFunc ) hb_itemCopy( hbza_ChangeDiskBlock, pFunc );