00001 #include <stdio.h>
00002 #include <iostream>
00003
00004 #define GLOBAL_PERSISTENT __attribute__ ((section("PERSISTENT")))
00005
00006 using namespace std;
00007
00008 extern "C" void * pmalloc(size_t);
00009 extern "C" void pfree(void *);
00010
00011 GLOBAL_PERSISTENT int state = 0;
00012 GLOBAL_PERSISTENT void *globalptr = 0;
00013
00014 main()
00015 {
00016 void *ptr;
00017 switch(state) {
00018 case 0:
00019 ptr = pmalloc(100);
00020 cout << "pmalloc: " << ptr << endl;
00021 globalptr = ptr;
00022 state = 1;
00023 break;
00024 case 1:
00025 cout << "pfree: " << globalptr << endl;
00026 pfree(globalptr);
00027 state = 0;
00028 break;
00029 }
00030 }