---
title: flexda_custom_init_ctx
description: 用户初始化自定义上下文。
url: "https://www.hikunpeng.com/document/detail/zh/flexda/api/dpak_api023.html"
---

# flexda_custom_init_ctx

#### 接口功能

用户初始化自定义上下文。


#### 接口格式

int flexda_custom_init_ctx(void **ctx)


#### 参数说明

| 参数名 | 参数类型 | 入参/出参 | 说明 |
| --- | --- | --- | --- |
| ctx | void \*\* | 入参 | 自定义上下文指针地址。 |
| 函数返回值 | int | 出参 | 若函数执行成功则返回0，若函数执行失败则返回错误码。 |


#### 使用实例

```
int flexda_custom_init_ctx(void **ctx_addr)
{
// 此处struct custom_packet_ctx为用户自定义报文上下文结构体，
struct custom_packet_ctx *ctx = (struct custom_packet_ctx *)flexda_calloc(1, sizeof(struct custom_packet_ctx));
*ctx_addr = (void *)ctx;
return 0;
}
```
