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

#### 功能说明

申请指定大小的共享Buffer。


#### 函数原型

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


#### 参数说明

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


#### 返回值说明

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