> ## 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.

# game_chat_allocate_memory_callback

> game_chat_allocate_memory_callback

# game\_chat\_allocate\_memory\_callback

每當 Game Chat 程式庫必須動態配置新的記憶體緩衝區時所叫用的回呼。

## 語法

```cpp theme={null}
typedef
_Ret_maybenull_
_Post_writable_byte_size_(size) void *
(game_chat_callback * game_chat_allocate_memory_callback)(
    _In_ size_t size,
    _In_ uint32_t memoryTypeId
    );
```

### 參數

*size*   \_In\_\
類型：size\_t

要進行之配置的大小。此值永遠不會是零。

*memoryTypeId*   \_In\_\
類型：uint32\_t

指向所指定大小之已配置記憶體區塊的指標，如果配置失敗則為 null 指標。

## 備註

您可以選擇使用 chat\_manager::set\_memory\_callbacks() 方法安裝此回呼。

此回呼必須配置並傳回指向所指定大小之連續記憶體區塊的指標，該區塊必須保持有效，
直到叫用應用程式對應的 [game\_chat\_free\_memory\_callback](/zh-TW/reference/chat/gamechat2/functions/game_chat_free_memory_callback) 將其釋放為止。
如果無法做到，回呼必須傳回 null 指標，使配置失敗。記憶體配置失敗
有時會被視為無害，但通常會導致目前的 Game Chat 程式庫作業失敗。

## 需求

**標頭：** GameChat2.h

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[GameChat2 成員](/zh-TW/reference/chat/gamechat2/gamechat2_members)\
[chat\_manager::get\_memory\_callbacks](/zh-TW/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_memory_callbacks)\
[chat\_manager::set\_memory\_callbacks](/zh-TW/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks)


## Related topics

- [game_chat_allocate_memory_callback](/ja-jp/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback.md)
- [game_chat_free_memory_callback](/reference/chat/gamechat2/functions/game_chat_free_memory_callback.md)
- [chat_manager::get_memory_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_memory_callbacks.md)
- [chat_manager::set_memory_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks.md)
