ecp_memalloc

ecp_memalloc函数定义在miracl.h,在mrcore.c中实现。

extern void* ecp_memalloc(_MIPT_ int);

函数功能:为epoint分配堆内存。

参数num:整数。

1. 源码分析

ecp_memalloc函数实现的相关内容如下。

void *ecp_memalloc(_MIPD_ int num)
{
#ifdef MR_OS_THREADS
    miracl *mr_mip=get_mip();
#endif

#ifndef MR_AFFINE_ONLY
    if (mr_mip->coord==MR_AFFINE)
        return mr_alloc(_MIPP_  mr_ecp_reserve_a(num,mr_mip->nib-1),1);
    else
#endif
        return mr_alloc(_MIPP_  mr_ecp_reserve(num,mr_mip->nib-1),1);
}

get_mip返回miracl *指针,如果没有定义MR_OS_THREADS,由_MIPD_接收。

一般情况下,用mr_ecp_reserve计算需要申请的字节数,当声明MR_AFFINE_ONLY,用mr_ecp_reserve_a计算需要申请的字节数。

© phdlisl all right reserved,powered by GitbookUpdate in 2025-10-11

results matching ""

    No results matching ""