Esempio n. 1
0
        // Get the size of a heap entry, NOT including the header
        // This works by returning the size of the type, unless the type is an array or a string,
        // which are the only two type that can have variable sizes
        static uint GetSize(tHeapEntry *pHeapEntry)
        {
            tMD_TypeDef *pType = pHeapEntry->pTypeDef;

            if (MetaData.TYPE_ISARRAY(pType))
            {
                // If it's an array, return the array length * array element size
                return(System_Array.GetNumBytes(null /* This is ok */, (/*HEAP_PTR*/ byte *)(pHeapEntry + 1), pType->pArrayElementType));
            }
            // If it's not array, just return the instance memory size
            return(pType->instanceMemSize);
        }
Esempio n. 2
0
        // Get the size of a heap entry, NOT including the header
        // This works by returning the size of the type, unless the type is an array or a string,
        // which are the only two type that can have variable sizes
        static uint GetSize(tHeapEntry *pHeapEntry)
        {
            tMD_TypeDef *pType = pHeapEntry->pTypeDef;

            if (pType == Type.types[Type.TYPE_SYSTEM_STRING])
            {
                // If it's a string, return the string length in bytes
                return(System_String.GetNumBytes((/*HEAP_PTR*/ byte *)(pHeapEntry + 1)));
            }
            if (MetaData.TYPE_ISARRAY(pType))
            {
                // If it's an array, return the array length * array element size
                return(System_Array.GetNumBytes(null /* This is ok */, (/*HEAP_PTR*/ byte *)(pHeapEntry + 1), pType->pArrayElementType));
            }
            // If it's not string or array, just return the instance memory size
            return(pType->instanceMemSize);
        }