---
title: aclrtGetBufDataLen
description: "获取共享Buffer中有效数据的长度。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclcppdevg_03_1907.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_1907.html
indexId: 18372062e57ba200cf8cc1b62e7dce589e273fecf66b90379920c4b1a6ebcd3e68
---
# aclrtGetBufDataLen

#### 功能说明

获取共享Buffer中有效数据的长度。

通过aclrtSetBufDataLen接口设置共享Buffer中有效数据的长度后，可调用本接口获取有效数据的长度，否则，通过本接口获取到的长度为0。


#### 函数原型

```
aclError aclrtGetBufDataLen(aclrtMbuf buf, size_t *len)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| buf | 输入 | 共享Buffer，类型定义请参见aclrtMbuf。 须通过aclrtAllocBuf或aclrtCopyBufRef接口申请获得。 |
| len | 输出 | 有效数据的长度，单位为Byte。 |


#### 返回值说明

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