Win32 API 日本語リファレンス
ホームGlobalization › u_setMemoryFunctions

u_setMemoryFunctions

関数
ICUが使用するメモリ確保関数を独自に設定する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

void u_setMemoryFunctions(
    const void* context,
    UMemAllocFn* a,
    UMemReallocFn* r,
    UMemFreeFn* f,
    UErrorCode* status
);

パラメーター

名前方向
contextvoid*in
aUMemAllocFn*inout
rUMemReallocFn*inout
fUMemFreeFn*inout
statusUErrorCode*inout

戻り値の型: void

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

void u_setMemoryFunctions(
    const void* context,
    UMemAllocFn* a,
    UMemReallocFn* r,
    UMemFreeFn* f,
    UErrorCode* status
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void u_setMemoryFunctions(
    IntPtr context,   // void*
    IntPtr a,   // UMemAllocFn* in/out
    IntPtr r,   // UMemReallocFn* in/out
    IntPtr f,   // UMemFreeFn* in/out
    ref int status   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub u_setMemoryFunctions(
    context As IntPtr,   ' void*
    a As IntPtr,   ' UMemAllocFn* in/out
    r As IntPtr,   ' UMemReallocFn* in/out
    f As IntPtr,   ' UMemFreeFn* in/out
    ByRef status As Integer   ' UErrorCode* in/out
)
End Sub
' context : void*
' a : UMemAllocFn* in/out
' r : UMemReallocFn* in/out
' f : UMemFreeFn* in/out
' status : UErrorCode* in/out
Declare PtrSafe Sub u_setMemoryFunctions Lib "icuuc" ( _
    ByVal context As LongPtr, _
    ByVal a As LongPtr, _
    ByVal r As LongPtr, _
    ByVal f As LongPtr, _
    ByRef status As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

u_setMemoryFunctions = ctypes.cdll.icuuc.u_setMemoryFunctions
u_setMemoryFunctions.restype = None
u_setMemoryFunctions.argtypes = [
    ctypes.POINTER(None),  # context : void*
    ctypes.c_void_p,  # a : UMemAllocFn* in/out
    ctypes.c_void_p,  # r : UMemReallocFn* in/out
    ctypes.c_void_p,  # f : UMemFreeFn* in/out
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
u_setMemoryFunctions = Fiddle::Function.new(
  lib['u_setMemoryFunctions'],
  [
    Fiddle::TYPE_VOIDP,  # context : void*
    Fiddle::TYPE_VOIDP,  # a : UMemAllocFn* in/out
    Fiddle::TYPE_VOIDP,  # r : UMemReallocFn* in/out
    Fiddle::TYPE_VOIDP,  # f : UMemFreeFn* in/out
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOID, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn u_setMemoryFunctions(
        context: *const (),  // void*
        a: *mut *const core::ffi::c_void,  // UMemAllocFn* in/out
        r: *mut *const core::ffi::c_void,  // UMemReallocFn* in/out
        f: *mut *const core::ffi::c_void,  // UMemFreeFn* in/out
        status: *mut i32  // UErrorCode* in/out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void u_setMemoryFunctions(IntPtr context, IntPtr a, IntPtr r, IntPtr f, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_setMemoryFunctions' -Namespace Win32 -PassThru
# $api::u_setMemoryFunctions(context, a, r, f, status)
#uselib "icuuc.dll"
#func global u_setMemoryFunctions "u_setMemoryFunctions" sptr, sptr, sptr, sptr, sptr
; u_setMemoryFunctions context, a, r, f, status
; context : void* -> "sptr"
; a : UMemAllocFn* in/out -> "sptr"
; r : UMemReallocFn* in/out -> "sptr"
; f : UMemFreeFn* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
#uselib "icuuc.dll"
#func global u_setMemoryFunctions "u_setMemoryFunctions" sptr, sptr, sptr, sptr, int
; u_setMemoryFunctions context, a, r, f, status
; context : void* -> "sptr"
; a : UMemAllocFn* in/out -> "sptr"
; r : UMemReallocFn* in/out -> "sptr"
; f : UMemFreeFn* in/out -> "sptr"
; status : UErrorCode* in/out -> "int"
; void u_setMemoryFunctions(void* context, UMemAllocFn* a, UMemReallocFn* r, UMemFreeFn* f, UErrorCode* status)
#uselib "icuuc.dll"
#func global u_setMemoryFunctions "u_setMemoryFunctions" intptr, intptr, intptr, intptr, int
; u_setMemoryFunctions context, a, r, f, status
; context : void* -> "intptr"
; a : UMemAllocFn* in/out -> "intptr"
; r : UMemReallocFn* in/out -> "intptr"
; f : UMemFreeFn* in/out -> "intptr"
; status : UErrorCode* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procu_setMemoryFunctions = icuuc.NewProc("u_setMemoryFunctions")
)

// context (void*), a (UMemAllocFn* in/out), r (UMemReallocFn* in/out), f (UMemFreeFn* in/out), status (UErrorCode* in/out)
r1, _, err := procu_setMemoryFunctions.Call(
	uintptr(context),
	uintptr(a),
	uintptr(r),
	uintptr(f),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure u_setMemoryFunctions(
  context: Pointer;   // void*
  a: Pointer;   // UMemAllocFn* in/out
  r: Pointer;   // UMemReallocFn* in/out
  f: Pointer;   // UMemFreeFn* in/out
  status: Pointer   // UErrorCode* in/out
); cdecl;
  external 'icuuc.dll' name 'u_setMemoryFunctions';
result := DllCall("icuuc\u_setMemoryFunctions"
    , "Ptr", context   ; void*
    , "Ptr", a   ; UMemAllocFn* in/out
    , "Ptr", r   ; UMemReallocFn* in/out
    , "Ptr", f   ; UMemFreeFn* in/out
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: void
●u_setMemoryFunctions(context, a, r, f, status) = DLL("icuuc.dll", "int u_setMemoryFunctions(void*, void*, void*, void*, void*)")
# 呼び出し: u_setMemoryFunctions(context, a, r, f, status)
# context : void* -> "void*"
# a : UMemAllocFn* in/out -> "void*"
# r : UMemReallocFn* in/out -> "void*"
# f : UMemFreeFn* in/out -> "void*"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。