I thought you could just call the _TS_* APIs to get to teraspace memory without
a stub?
Is that not true?
-Bob Cozzi
www.i5PodCast.com
Ask your manager to watch i5 TV
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [
mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Steve Richter
Sent: Thursday, April 19, 2007 3:16 PM
To: RPG programming on the AS400 / iSeries
Subject: Teraspace works great in RPG
I've groused about the 16meg space limit on the system, thinking that
it cripples things like XML string processing. I knew about teraspace,
but never tried it, assuming that the system would require the entire
activation group to be teraspace space enabled or something. Was I
ever wrong!
RPG cant allocate teraspace directly, but it can copy to and from
teraspace memory. Most important, RPG can set its own pointers
anywhere within a 16meg+ sized teraspace allocation. All you need is
an ILE C module that contains a procedure that runs malloc to alloc
the space and another that runs free to free the teraspace. When the
C module is compiled simply compile with the following parms:
CRTCMOD MODULE(&MODLIB/&MODNAME) +
SRCFILE(&SRCFLIB/&SRCFNAME) +
SRCMBR(&SRCMBR) DBGVIEW(&DBGVIEW) +
TERASPACE(*YES *TSIFC) STGMDL(*SNGLVL) +
DTAMDL(*P128)
here are the C procs:
/* -------------------- tera_Alloc -------------------------- */
extern char*
tera_Alloc( int InSx )
{
char* pData ;
pData = malloc( InSx ) ;
return pData ;
}
/* -------------------- tera_Free ------------------------- */
extern void
tera_Free( void* pInData )
{
free( pInData ) ;
}
the RPG code requires no special create parameters. Here is the RPG
code that uses teraspace:
d pAlloc s *
d pData s *
d data s 80a based(pData)
d sx s 10i 0
d ox s 10i 0
/free
sx = 20000000 ;
pAlloc = tera_Alloc( sx ) ;
ox = sx - 1000000 ;
pData = pAlloc + ox ;
data = 'abc' ;
tera_Free( pAlloc ) ;
-Steve
As an Amazon Associate we earn from qualifying purchases.