---
title: aclrtAllocatorSetAllocAdviseFuncToDesc
description: "使用用户提供的Allocator场景下，设置\"根据建议地址申请内存block\"的回调函数，一般用于内存复用场景。"
url: https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/latest/Application%20Development%20Guide/aadgc/aclcppdevg_03_1967.html
sourcePath: /source/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application Development Guide/aadgc/aclcppdevg_03_1967.html
indexId: b04c25ef0ec5f8d53ba4f2dc5ce007bad4a0607ad886f4caa757ca27b5dc2799105
---
# aclrtAllocatorSetAllocAdviseFuncToDesc

#### 函数功能

使用用户提供的Allocator场景下，设置"根据建议地址申请内存block"的回调函数，一般用于内存复用场景。


#### 函数原型

aclError aclrtAllocatorSetAllocAdviseFuncToDesc(aclrtAllocatorDesc allocatorDesc, aclrtAllocatorAllocAdviseFunc func)


#### 参数说明

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


#### 返回值说明

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