1、首先确认定义你所需要的结构体
例如
typedef struct{
int allVoiceMsgNum;
int unreadVoiceMsgNum;
}tVoiceMsgListInfo;
2、用该结构体定义一个全局结构体指针gVoiceMsgListInfo
tVoiceMsgListInfo *gVoiceMsgListInfo = NULL;
3、动态的为gVoiceMsgListInfo 分配内存
gVoiceMsgListInfo = TKMEM_ZALLOCN(tVoiceMsgListInfo , sipNum);
分配内存用的是封装后的calloc函数,及分配sipNum倍个tVoiceMsgListInfo的空间
4、使用该指正时,相当于sipNum个数组,下标则代表第几个,可使用不同下标的结构体成员
gVoiceMsgListInfo[i].allVoiceMsgNum = vmsgCount.newMessage+ vmsgCount.oldMessage;
gVoiceMsgListInfo[i].unreadVoiceMsgNum = vmsgCount.newMessage;
这样就得到了多个结构体空间了,不过不要忘记在使用完释放掉内存 TKMEM_FREE(gVoiceMsgListInfo),防止出现内存泄漏问题