2001-09-13 06:02 UTC+0100 Viktor Szakats <viktor.szakats@syenar.hu>

This commit is contained in:
Viktor Szakats
2001-09-13 04:04:14 +00:00
parent 061fc2b32e
commit bc990c32c6
2 changed files with 36 additions and 25 deletions

View File

@@ -1,3 +1,10 @@
2001-09-13 06:02 UTC+0100 Viktor Szakats <viktor.szakats@syenar.hu>
* source/vm/arrays.c
! hb_arraySize() fixed. Now it will do nothing if the passed size
equals with the size of passed array. Caused mem. alloc. error
with empty arrays. Reported by Brian Hays.
2001-09-11 10:37 GMT Dave Pearson <davep@davep.org>
* source/rtl/profiler.prg
* Renamed classes from HB_* to HB*.

View File

@@ -152,43 +152,47 @@ BOOL hb_arraySize( PHB_ITEM pArray, ULONG ulLen )
if( HB_IS_ARRAY( pArray ) )
{
PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
ULONG ulPos;
if( ! pBaseArray->ulLen )
if( ulLen != pBaseArray->ulLen )
{
pBaseArray->pItems = ( PHB_ITEM ) hb_xgrab( ulLen * sizeof( HB_ITEM ) );
ULONG ulPos;
for( ulPos = 0; ulPos < ulLen; ulPos++ )
( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
}
else
{
if( pBaseArray->ulLen < ulLen )
if( pBaseArray->ulLen == 0 )
{
pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * ulLen );
/* set value for new items */
for( ulPos = pBaseArray->ulLen; ulPos < ulLen; ulPos++ )
pBaseArray->pItems = ( PHB_ITEM ) hb_xgrab( ulLen * sizeof( HB_ITEM ) );
for( ulPos = 0; ulPos < ulLen; ulPos++ )
( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
}
else if( pBaseArray->ulLen > ulLen )
else
{
/* release old items */
for( ulPos = ulLen; ulPos < pBaseArray->ulLen; ulPos++ )
hb_itemClear( pBaseArray->pItems + ulPos );
if( ulLen == 0 )
if( pBaseArray->ulLen < ulLen )
{
hb_xfree( pBaseArray->pItems );
pBaseArray->pItems = NULL;
}
else
pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * ulLen );
/* set value for new items */
for( ulPos = pBaseArray->ulLen; ulPos < ulLen; ulPos++ )
( pBaseArray->pItems + ulPos )->type = HB_IT_NIL;
}
else if( pBaseArray->ulLen > ulLen )
{
/* release old items */
for( ulPos = ulLen; ulPos < pBaseArray->ulLen; ulPos++ )
hb_itemClear( pBaseArray->pItems + ulPos );
if( ulLen == 0 )
{
hb_xfree( pBaseArray->pItems );
pBaseArray->pItems = NULL;
}
else
pBaseArray->pItems = ( PHB_ITEM ) hb_xrealloc( pBaseArray->pItems, sizeof( HB_ITEM ) * ulLen );
}
}
pBaseArray->ulLen = ulLen;
}
pBaseArray->ulLen = ulLen;
return TRUE;
}
else