---
title: aclrtAllocBuf
description: "申请指定大小的共享Buffer。"
url: https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/latest/API/runtimeapi/aclcppdevg_03_1910.html
sourcePath: /source/zh/CANNCommunityEdition/920beta1/API/runtimeapi/aclcppdevg_03_1910.html
indexId: 1c27930133209ccca088a208622477312a1e5c96c54ba9ff386b98ca51b9af2b79
---
# aclrtAllocBuf

#### 功能说明

申请指定大小的共享Buffer。


#### 函数原型

```
aclError aclrtAllocBuf(aclrtMbuf *buf, size_t size)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| buf | 输出 | 申请到的共享Buffer。类型定义请参见aclrtMbuf。 |
| size | 输入 | 用于指定数据区的内存大小，单位Byte，不能超过4G。 |


#### 返回值说明

返回0表示成功，返回其他值表示失败，请参见aclError。
