MapleAlloc - allocate memory in external code
MapleDispose - free memory in external code
|
Calling Sequence
|
|
MapleAlloc(kv, n)
MapleDispose(kv, s)
|
|
Parameters
|
|
kv
|
-
|
kernel handle of type MKernelVector
|
n
|
-
|
number of bytes to allocate
|
s
|
-
|
type ALGEB object
|
|
|
|
|
Description
|
|
•
|
MapleAlloc allocates n bytes of memory and returns a pointer to it. MapleDispose frees this memory so it can be reused for other purposes.
|
•
|
MapleAlloc is used to access temporary memory that will be cleaned up by the Maple garbage collector. The memory returned by MapleAlloc cannot be protected from gc. To allocate memory that persists, use standard non-Maple memory allocation methods in combination with a MaplePointer.
|
•
|
MapleDispose releases the memory allocated to the structure s. It must be used only on data structures created using MapleAlloc.
|
|
|
Examples
|
|
#include <stdio.h>
|
#include "maplec.h"
|
ALGEB M_DECL MyConcat( MKernelVector kv, ALGEB *args )
|
{
|
char *name, *tmp;
|
FLOAT64 f;
|
size_t len;
|
if( MapleNumArgs(kv,(ALGEB)args) != 2 ) {
|
MapleRaiseError(kv,"two arguments expected");
|
return( NULL );
|
}
|
name = MapleToString(kv,args[1]);
|
f = MapleToFloat64(kv,args[2]);
|
len = strlen(name);
|
tmp = (char*)MapleAlloc(kv,(len+30)*sizeof(char));
|
sprintf(tmp,"%s%f",name,f);
|
return( ToMapleName(kv,tmp,FALSE) );
|
}
|
|
|
Execute the external function from Maple.
>
|
|
>
|
|
>
|
|
>
|
|
| (1) |
>
|
|
>
|
|
| (2) |
Note: The name returned is local (it does not match the global name).
>
|
|
| (3) |
>
|
|
NAME(100002AAAAE8A2256,5): `foo1.100000`
| |
>
|
|
NAME(100002AAAAE8A3346,5): `foo1.100000`
| |
|
|
Download Help Document
Was this information helpful?