From a947b503ce6063d6cc54ba9907eb332378eda14b Mon Sep 17 00:00:00 2001 From: Jean-Francois Lefebvre Date: Thu, 11 Oct 2001 21:04:15 +0000 Subject: [PATCH] 2001-10-11 23:05 GMT+1 JFL (mafact) --- harbour/ChangeLog | 6 +++++ harbour/source/vm/classes.c | 15 ++++++++----- harbour/source/vm/hvm.c | 45 ++++++++++++++++++++++++++++++++----- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1cf5c391de..3626adcf34 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +2001-10-11 23:05 GMT+1 JFL (mafact) + * harbour/source/vm/classes.c + * harbour/source/vm/hvm.c + * Changed the way I allocate/reallocate and xfree 'puiClstree' pointer + to solve unreleased memory blocks ... + 2001-10-11 21:45 GMT+3 Alexander Kresin ! source/pp/pptable.c * Rule corrected diff --git a/harbour/source/vm/classes.c b/harbour/source/vm/classes.c index 3b04d1034d..63134d61e9 100644 --- a/harbour/source/vm/classes.c +++ b/harbour/source/vm/classes.c @@ -639,7 +639,7 @@ char * hb_objGetRealClsName( PHB_ITEM pObject, char * szName ) uiClass = pObject->item.asArray.value->uiClass; /* default value to current class object */ - if (pObject->item.asArray.value->puiClsTree[0]) + if (pObject->item.asArray.value->puiClsTree && pObject->item.asArray.value->puiClsTree[0]) { uiClsTree = pObject->item.asArray.value->puiClsTree[0] ; uiCurCls = pObject->item.asArray.value->puiClsTree[uiClsTree] ; @@ -1437,8 +1437,10 @@ static PHB_ITEM hb_clsInst( USHORT uiClass ) pSelf->item.asArray.value->uiClass = uiClass; pSelf->item.asArray.value->uiPrevCls = 0; - pSelf->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); - pSelf->item.asArray.value->puiClsTree[0]=0; + pSelf->item.asArray.value->puiClsTree = NULL; + + //pSelf->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); + //pSelf->item.asArray.value->puiClsTree[0]=0; /* Initialise value if initialisation was requested */ pMeth = pClass->pMethods; @@ -1639,8 +1641,11 @@ HB_FUNC( __OBJCLONE ) if( pSrcObject ) { pDstObject= hb_arrayClone( pSrcObject, NULL ) ; - pDstObject->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); - pDstObject->item.asArray.value->puiClsTree[0]=0; + + pDstObject->item.asArray.value->puiClsTree = NULL; + //pDstObject->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); + //pDstObject->item.asArray.value->puiClsTree[0]=0; + hb_itemRelease( hb_itemReturn( pDstObject ) ); } else diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 83d8a106bd..d08b65394e 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -3025,6 +3025,12 @@ void hb_vmDo( USHORT uiParams ) /* Push current SuperClass handle */ lPopSuper = TRUE ; + if ( ! pSelf->item.asArray.value->puiClsTree) + { + pSelf->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); + pSelf->item.asArray.value->puiClsTree[0]=0; + } + nPos=pSelfBase->puiClsTree[0]+1; pSelfBase->puiClsTree = ( USHORT * ) hb_xrealloc( pSelfBase->puiClsTree, sizeof( USHORT ) * ( nPos + 1 ) ); @@ -3042,12 +3048,22 @@ void hb_vmDo( USHORT uiParams ) pFunc(); - if (lPopSuper) + if (lPopSuper && pSelfBase->puiClsTree) { + USHORT nPos=pSelfBase->puiClsTree[0]-1; /* POP SuperClass handle */ - pSelfBase->puiClsTree = ( USHORT * ) hb_xrealloc( pSelfBase->puiClsTree, sizeof( USHORT ) * (nPos + 1) ); - pSelfBase->puiClsTree[0]=nPos; + + if (nPos) + { + pSelfBase->puiClsTree = ( USHORT * ) hb_xrealloc( pSelfBase->puiClsTree, sizeof( USHORT ) * (nPos + 1) ); + pSelfBase->puiClsTree[0]=nPos; + } + else + { + hb_xfree(pSelfBase->puiClsTree); + pSelfBase->puiClsTree = NULL ; + } } @@ -3170,6 +3186,14 @@ void hb_vmSend( USHORT uiParams ) /* Push current SuperClass handle */ lPopSuper = TRUE ; + + + if ( ! pSelf->item.asArray.value->puiClsTree) + { + pSelf->item.asArray.value->puiClsTree = ( USHORT * ) hb_xgrab( sizeof( USHORT ) ); + pSelf->item.asArray.value->puiClsTree[0]=0; + } + nPos=pSelfBase->puiClsTree[0]+1; pSelfBase->puiClsTree = ( USHORT * ) hb_xrealloc( pSelfBase->puiClsTree, sizeof( USHORT ) * (nPos+1) ) ; pSelfBase->puiClsTree[0] = nPos ; @@ -3183,12 +3207,21 @@ void hb_vmSend( USHORT uiParams ) pFunc(); - if (lPopSuper) + if (lPopSuper && pSelfBase->puiClsTree) { USHORT nPos=pSelfBase->puiClsTree[0]-1; /* POP SuperClass handle */ - pSelfBase->puiClsTree = ( USHORT * ) hb_xrealloc( pSelfBase->puiClsTree, sizeof( USHORT ) * (nPos + 1) ); - pSelfBase->puiClsTree[0]=nPos; + if (nPos) + { + pSelfBase->puiClsTree = ( USHORT * ) hb_xrealloc( pSelfBase->puiClsTree, sizeof( USHORT ) * (nPos + 1) ); + pSelfBase->puiClsTree[0]=nPos; + } + else + { + hb_xfree(pSelfBase->puiClsTree); + pSelfBase->puiClsTree = NULL ; + } + } if( bProfiler )