OpenMaple/C/MaplePushGMPAllocators - Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : OpenMaple/C/MaplePushGMPAllocators

MaplePushGMPAllocators

push a set of GMP memory management functions

MaplePopGMPAllocators

pop a set of GMP memory management functions

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

MaplePushGMPAllocators(kv, void *(GMP_DECL *malloc)( size_t ), void *(GMP_DECL *realloc)( void *, size_t, size_t ), void (GMP_DECL *free)( void *, size_t ) )

MaplePopGMPAllocators(kv)

Parameters

kv

-

kernel handle of type MKernelVector

malloc, realloc, free

-

memory management functions for GMP

Description

• 

Maple uses the GMP library internally to perform integer calculations. If an external call library wants to use the GMP library, it should override the GMP memory management functions.

• 

The MaplePushGMPAllocator and MaplePopGMPAllocator functions allow external code to register set of thread local memory management functions without interfering with Maple's internal memory management.

• 

GMP's function mp_set_memory_functions should not be used in a Maple external calling library.

• 

If an exception occurs between a call to MaplePushGMPAllocators and MaplePopGMPAllocators, the pushed GMP allocators will be automatically popped off the stack, so there is no need to call MaplePopGMPAllocators.

• 

These functions can only be called from threads created within Maple or registered with the MapleRegisterThread function.

Examples

#include "maplec.h"

 

ALGEB M_DECL DoGMPWork( MKernelVector kv, ALGEB *args )

{

    MaplePushGMPAllocators( kv, ext_malloc, ext_realloc, ext_free );

    CallGMPRoutines( args );

    MaplePopGMPAllocators( kv );

    return ToMapleNULL( kv );

}

See Also

CustomWrapper

define_external

eval

OpenMaple

OpenMaple/C/API

OpenMaple/C/Examples