---
title: aclrtAllocatorSetAllocFuncToDesc
description: "使用用户提供的Allocator场景下，设置\"申请内存block\"的回调函数。"
url: https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/latest/Application%20Development%20Guide/aadgc/aclcppdevg_03_1966.html
sourcePath: /source/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application Development Guide/aadgc/aclcppdevg_03_1966.html
indexId: 9d9a93777af3289aac33ca0ec8b200d8d3a03927f205eacaad0f1c7d9da6cc58105
---
# aclrtAllocatorSetAllocFuncToDesc

#### 函数功能

使用用户提供的Allocator场景下，设置"申请内存block"的回调函数。


#### 函数原型

aclError aclrtAllocatorSetAllocFuncToDesc(aclrtAllocatorDesc allocatorDesc, aclrtAllocatorAllocFunc func)


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| allocatorDesc | 输入 | Allocator描述符指针。 需提前调用aclrtAllocatorCreateDesc接口设置Allocator描述信息。 |
| func | 输入 | 申请内存block的回调函数。 回调函数定义如下： typedef void \*(\*aclrtAllocatorAllocFunc)(aclrtAllocator allocator, size\_t size); aclrtAllocator的定义如下： typedef void \*aclrtAllocator; |


#### 返回值说明

返回0表示成功，返回其它值表示失败。
