0クリア済みメモリブロックの割り当て

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static IntPtr fnOAL_calloc(
	SIZE_T num,
	SIZE_T size
)
Visual Basic
Public Shared Function fnOAL_calloc ( 
	num As SIZE_T,
	size As SIZE_T
) As IntPtr

Parameters

num
Type: fvalgcli..::..SIZE_T
要素の数
size
Type: fvalgcli..::..SIZE_T
各要素のバイト単位の長さ

Return Value

Type: IntPtr
正常に終了した場合は、割り当てられたメモリブロックへのポインタを返します。 メモリ不足などで、異常終了した場合には IntPtr.Zero を返します。 解放する際は fnOAL_free(IntPtr) を使用してください。

Remarks

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// 0クリア済みメモリブロックの割り当て.
        /// </summary>
        [FvPluginExecute]
        public void fnOAL_calloc()
        {
            PNT_T_PTR mem = PNT_T_PTR.Zero;
            uint num = 1024;
            SIZE_T size = PNT_T_PTR.SizeOfItem;

            try
            {
                // 確保.
                mem = api.fnOAL_calloc(num, size);

                // エラー判定.
                Assert.IsTrue(mem != PNT_T_PTR.Zero, "fnOAL_calloc: エラーが発生しました。");
                for (int i = 0; i < size; i++)
                {
                    Assert.IsTrue(mem[i].x == 0, "メモリーが0クリアされていません。");
                    Assert.IsTrue(mem[i].y == 0, "メモリーが0クリアされていません。");
                }
            }
            finally
            {
                // メモリブロックの開放.
                api.fnOAL_free(mem);
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' 0クリア済みメモリブロックの割り当て.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnOAL_calloc()
        Dim mem As PNT_T_PTR = PNT_T_PTR.Zero
        Dim num As UInteger = 1024
        Dim size As SIZE_T = PNT_T_PTR.SizeOfItem

        Try
            ' 確保.
            mem = api.fnOAL_calloc(num, size)

            ' エラー判定.
            Assert.IsTrue(mem <> PNT_T_PTR.Zero, "fnOAL_calloc: エラーが発生しました。")
            Dim iloop As Integer = size.ToInt32() - 1
            For i As Integer = 0 To iloop
                Assert.IsTrue(mem(i).x = 0, "メモリーが0クリアされていません。")
                Assert.IsTrue(mem(i).y = 0, "メモリーが0クリアされていません。")
            Next
        Finally
            ' メモリブロックの開放.
            api.fnOAL_free(mem)
        End Try
    End Sub
End Class

See Also