指针的指针一般用法是外部人申明,传入另一个函数以后由这个函数申请空间,但是需要注意的是,要在传入之前给这个指针的指针初始化。
例如
#include<stdio.h>
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef struct
{
u16 value_handle;
u8 offset;
u8 *data;
u16 len;
} ble_gatts_write_t;
typedef struct
{
u16 value_handle;
u8 offset;
u8 **data;
u16 *len;
} ble_gatts_read_t;
typedef struct ble_gatts_evt_param{
u16 conn_handle;
union
{
ble_gatts_write_t write;
ble_gatts_read_t read;
};
}ble_gatts_evt_param_t;
void ble_cae_gatts_callback(ble_gatts_evt_param_t *param){
printf("ble_cae_gatts_callback enter\n");
u8 *read_data = NULL;
u16 read_data_len = 3;
read_data = (u8 *)malloc(3);
if(NULL == read_data){
printf("11111111111111111111111");
return ;
}
printf("ble_cae_gatts_callback 1\n");
read_data[0] = 0x32;
read_data[1] = 0xff;
read_data[2] = 0x00;
printf("ble_cae_gatts_callback 2\n");
*param->read.data = read_data;
printf("ble_cae_g