> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ApuAlloc

> ApuAlloc

# ApuAlloc

APU 物理メモリを割り当てます。

## 構文

```cpp theme={null}
HRESULT ApuAlloc(  
         void** virtualAddress,  
         APU_ADDRESS* physicalAddress,  
         UINT32 sizeInBytes,  
         UINT32 alignmentInBytes = 4,  
         UINT32 flags = APU_ALLOC_CACHED  
)  
```

### パラメーター

*virtualAddress*   \_Result\_nullonfailure\_ \_Outptr\_result\_bytebuffer\_(sizeInBytes)\
型: void\*\*

返される仮想アドレス。

*physicalAddress*   \_Result\_zeroonfailure\_ \_Out\_opt\_\
型: APU\_ADDRESS\*

返される `APU_ADDRESS`。APU での使用向け。

*sizeInBytes*   \_In\_\
型: UINT32

割り当てるサイズ (バイト単位)。

*alignmentInBytes*   \_In\_\
型: UINT32

アラインメント (バイト単位)。2 のべき乗であり、かつ 4 以上でなければなりません。

*flags*\
型: UINT32

割り当てフラグ: `APU_ALLOC_CACHED` または `APU_ALLOC_NONCACHED`。

### 戻り値

型: HRESULT

このメソッドは次の値を返す可能性があります。

| 戻り値コード         | 説明                                                                                                                                     |
| :------------- | :------------------------------------------------------------------------------------------------------------------------------------- |
| S\_OK          | 成功                                                                                                                                     |
| E\_INVALIDARG  | 無効な引数 (virtual address == nullptr、size == 0、alignment == 0、(alignment & 0x3) != 0、(alignment & (alignment - 1)) != 0、または無効な flags 値など) |
| E\_OUTOFMEMORY | メモリ割り当ての失敗                                                                                                                             |

## 解説

返される仮想アドレスと物理アドレスは、同じアドレス空間の異なるビューを表します。一方を解放すると他方も無効になります。割り当てを解放するには、[ApuFree](/reference/audio/apu/functions/apufree) を使用します。

## 要件

**ヘッダー:** apu.h

**ライブラリ:** acphal.lib

**サポート対象プラットフォーム:** XBOX One ファミリー本体、XBOX Series 本体

## 概念ドキュメント

* [XMA2 の概要](/build/console-features/audio/overviews/xma2-overview)

## 関連項目

[ApuFree](/reference/audio/apu/functions/apufree)\
[APU](/reference/audio/apu/apu_members)


## Related topics

- [ApuFree](/ja-jp/reference/audio/apu/functions/apufree.md)
- [ApuMapApuAddress](/ja-jp/reference/audio/apu/functions/apumapapuaddress.md)
- [XMA2 の概要](/ja-jp/build/console-features/audio/overviews/xma2-overview.md)
- [ApuMapVirtualAddress](/ja-jp/reference/audio/apu/functions/apumapvirtualaddress.md)
- [APU (Audio Processing Unit)](/ja-jp/reference/audio/apu/apu_members.md)
