Index: trunk/Include/system/exception.ab
===================================================================
--- trunk/Include/system/exception.ab	(revision 421)
+++ trunk/Include/system/exception.ab	(revision 422)
@@ -93,6 +93,5 @@
 
 Class ExceptionService
-	ppTryLayers As **TryLayer
-	nTryLayers As Long
+	tryLayers As System.Collections.Generic.List<TryLayer>
 
 	Sub FreeLocalObjects()
@@ -102,23 +101,15 @@
 
 	Sub ExceptionService()
-		ppTryLayers = _System_malloc( 1 )
-		nTryLayers = 0
+		tryLayers = New System.Collections.Generic.List<TryLayer>
 	End Sub
 	Sub ~ExceptionService()
-		Dim i As Long
-		For i = 0 To ELM( nTryLayers )
-			Delete ppTryLayers[i]
-		Next
-		_System_free( ppTryLayers )
-		ppTryLayers = 0
 	End Sub
 
 	'Try
 	Function _BeginTryScope( catchTable As *LONG_PTR, addressOfFinally As VoidPtr, basePtr As LONG_PTR, stackPtr As LONG_PTR ) As TryLayer
-		ppTryLayers = _System_realloc( ppTryLayers, ( nTryLayers + 1 ) * SizeOf( *TryLayer ) )
-		ppTryLayers[nTryLayers] = New TryLayer( catchTable, addressOfFinally, basePtr, stackPtr )
-		nTryLayers++
-
-		Return ByVal ppTryLayers[nTryLayers-1]
+		Dim tryLayer = New TryLayer( catchTable, addressOfFinally, basePtr, stackPtr )
+		tryLayers.Add( tryLayer )
+
+		Return tryLayer
 	End Function
 
@@ -129,11 +120,10 @@
 	'End Try
 	Sub EndTryScope()
-		nTryLayers--
-		Delete ppTryLayers[nTryLayers]
+		tryLayers.RemoveAt( tryLayers.Count - 1 )
 	End Sub
 
 	'Throw
 	Sub _Throw( ex As Object )
-		If nTryLayers <= 0 then
+		If tryLayers.Count <= 0 then
 			'例外処理スコープ制御が無効なとき
 
@@ -151,10 +141,10 @@
 		FreeLocalObjects()
 
-		Dim pTryLayer = ppTryLayers[nTryLayers - 1] As *TryLayer
-
-		Dim addressOfCatch = pTryLayer->ResolveCatchesOverload( ex ) As LONG_PTR
+		Dim tryLayer = tryLayers[tryLayers.Count - 1]
+
+		Dim addressOfCatch = tryLayer.ResolveCatchesOverload( ex ) As LONG_PTR
 		If addressOfCatch = NULL Then
 			' Catchが定義されていないときはFinallyへ誘導
-			addressOfCatch = pTryLayer->addressOfFinally As LONG_PTR
+			addressOfCatch = tryLayer.addressOfFinally As LONG_PTR
 		End If
 
@@ -174,10 +164,10 @@
 #ifdef _WIN64
 		context.Rip = addressOfCatch As QWord
-		context.Rbp = pTryLayer->basePtr
-		context.Rsp = pTryLayer->stackPtr
+		context.Rbp = tryLayer.basePtr
+		context.Rsp = tryLayer.stackPtr
 #else
 		context.Eip = addressOfCatch As DWord
-		context.Ebp = pTryLayer->basePtr
-		context.Esp = pTryLayer->stackPtr
+		context.Ebp = tryLayer.basePtr
+		context.Esp = tryLayer.stackPtr
 #endif
 
@@ -186,5 +176,5 @@
 		ThreadNum=_DebugSys_GetThread()
 		If ThreadNum <> -1 Then
-			_DebugSys_ProcNum[ThreadNum] = pTryLayer->debugProcNum-1
+			_DebugSys_ProcNum[ThreadNum] = tryLayer.debugProcNum-1
 		End If
 #endif
@@ -205,6 +195,6 @@
 
 	Sub FinishFinally()
-		Dim pTryLayer = ppTryLayers[nTryLayers - 1] As *TryLayer
-		pTryLayer->FinishFinally()
+		Dim tryLayer = tryLayers[tryLayers.Count - 1]
+		tryLayer.FinishFinally()
 	End Sub
 End Class
