用指针的指针分配若干块指针空间

来源:互联网 发布:js图像热点链接 编辑:程序博客网 时间:2024/05/19 00:54
#define PU_MD_MALLOC_RET( P, S, L, ret ) \
{ \
    P = NULL; \
    P = (S*) malloc(L); \
    if ( NULL == P ) return ret; \
    memset( P, 0, L ); \

}


#ifndef DECLARE_HANDLE
#define DECLARE_HANDLE(name) struct name##__{ int unused; }; typedef struct name##__ *name
#endif


int main()

{

DECLARE_HANDLE(HCaVideoEnc);

HCaVideoEnc*m_phVEnc;  

PU_MD_MALLOC_RET( m_phVEnc, HCaVideoEnc, sizeof( HCaVideoEnc ) * m_byVEncNum, FALSE );

return 0;

}


取指针内容:m_phVEnc[i];

取指针地址:&m_phVEnc[i];

原创粉丝点击