From 3bac3a62de3926a2914ba25a56b082fbc8d87c4e Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 22 May 2012 14:51:12 +0000 Subject: [PATCH] 2012-05-22 16:50 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/src/vm/arrays.c * allow to call hb_arrayId() with NULL parameter * harbour/include/hbapiitm.h * harbour/src/vm/itemapi.c + added internal HVM function hb_itemPutPtrRawGC() - it's necessary for blocks allocated with hb_gcAllocRaw(). * harbour/src/vm/thread.c ! use hb_itemPutPtrRawGC() instead of hb_itemPutPtrGC() It fixes internal errors (i.e. reported in build process) after my previous commit. --- harbour/ChangeLog | 12 ++++++++++++ harbour/include/hbapiitm.h | 2 ++ harbour/src/vm/arrays.c | 2 +- harbour/src/vm/itemapi.c | 20 ++++++++++++++++++++ harbour/src/vm/thread.c | 4 ++-- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2ab5e8aedf..07daa37bb0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,18 @@ The license applies to all entries newer than 2009-04-28. */ +2012-05-22 16:50 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/src/vm/arrays.c + * allow to call hb_arrayId() with NULL parameter + * harbour/include/hbapiitm.h + * harbour/src/vm/itemapi.c + + added internal HVM function hb_itemPutPtrRawGC() - it's + necessary for blocks allocated with hb_gcAllocRaw(). + * harbour/src/vm/thread.c + ! use hb_itemPutPtrRawGC() instead of hb_itemPutPtrGC() + It fixes internal errors (i.e. reported in build process) + after my previous commit. + 2012-05-22 14:42 UTC+0200 Viktor Szakats (harbour syenar.net) * INSTALL + updated platform compatibility matrix to use Markdown markup diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index 5ab5ef15ce..c2098396d5 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -187,6 +187,8 @@ extern HB_EXPORT PHB_ITEM hb_itemDeserialize( const char ** pBufferPtr, HB_S #if defined( _HB_API_INTERNAL_ ) +extern PHB_ITEM hb_itemPutPtrRawGC( PHB_ITEM pItem, void * pValue ); + # define hb_itemSetNil( item ) do { \ if( HB_IS_COMPLEX( item ) ) \ hb_itemClear( item ); \ diff --git a/harbour/src/vm/arrays.c b/harbour/src/vm/arrays.c index 06e5728826..78beef4b92 100644 --- a/harbour/src/vm/arrays.c +++ b/harbour/src/vm/arrays.c @@ -315,7 +315,7 @@ HB_BOOL hb_arrayIsObject( PHB_ITEM pArray ) /* retrives the array unique ID */ void * hb_arrayId( PHB_ITEM pArray ) { - if( HB_IS_ARRAY( pArray ) ) + if( pArray && HB_IS_ARRAY( pArray ) ) return ( void * ) pArray->item.asArray.value; else return NULL; diff --git a/harbour/src/vm/itemapi.c b/harbour/src/vm/itemapi.c index 44f0e272b1..f58f0a66e8 100644 --- a/harbour/src/vm/itemapi.c +++ b/harbour/src/vm/itemapi.c @@ -1384,6 +1384,26 @@ PHB_ITEM hb_itemPutPtrGC( PHB_ITEM pItem, void * pValue ) return pItem; } +PHB_ITEM hb_itemPutPtrRawGC( PHB_ITEM pItem, void * pValue ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_itemPutPtrRawGC(%p, %p)", pItem, pValue)); + + if( pItem ) + { + if( HB_IS_COMPLEX( pItem ) ) + hb_itemClear( pItem ); + } + else + pItem = hb_itemNew( NULL ); + + pItem->type = HB_IT_POINTER; + pItem->item.asPointer.value = pValue; + pItem->item.asPointer.collect = HB_TRUE; + pItem->item.asPointer.single = HB_FALSE; + + return pItem; +} + PHB_ITEM hb_itemPutSymbol( PHB_ITEM pItem, PHB_SYMB pSym ) { HB_TRACE(HB_TR_DEBUG, ("hb_itemPutSymbol(%p,%p)", pItem, pSym)); diff --git a/harbour/src/vm/thread.c b/harbour/src/vm/thread.c index b1c6b16e80..a4f273c1c0 100644 --- a/harbour/src/vm/thread.c +++ b/harbour/src/vm/thread.c @@ -1050,7 +1050,7 @@ PHB_THREADSTATE hb_threadStateNew( void ) pThread = ( PHB_THREADSTATE ) hb_gcAllocRaw( sizeof( HB_THREADSTATE ), &s_gcThreadFuncs ); memset( pThread, 0, sizeof( HB_THREADSTATE ) ); - hb_itemPutPtrGC( pThItm, pThread ); + hb_itemPutPtrRawGC( pThItm, pThread ); pThread->pszCDP = HB_MACRO2STRING( HB_CODEPAGE_DEFAULT ); pThread->pszLang = HB_MACRO2STRING( HB_LANG_DEFAULT ); @@ -1792,7 +1792,7 @@ PHB_ITEM hb_threadMutexCreate( void ) pItem = hb_itemNew( NULL ); pMutex = ( PHB_MUTEX ) hb_gcAllocRaw( sizeof( HB_MUTEX ), &s_gcMutexFuncs ); memset( pMutex, 0, sizeof( HB_MUTEX ) ); - pItem = hb_itemPutPtrGC( pItem, pMutex ); + pItem = hb_itemPutPtrRawGC( pItem, pMutex ); #if !defined( HB_MT_VM ) /* nothing */