home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 534.lha / vmalloc_v1.2 / test.c < prev    next >
C/C++ Source or Header  |  1991-08-08  |  894b  |  53 lines

  1.  
  2. #include "vm.h"
  3.  
  4. struct TrackBase *TrackBase ;
  5. struct DOSBase *DOSBase ;
  6.  
  7. struct VM_Construct *VM_C ;
  8. struct VM_Lock *VM_L ;
  9. struct VM_Lock *VM_L2 ;
  10. char *mem ;
  11.  
  12. void
  13. __saveds begin(void) {
  14.  
  15.    int i ;
  16.  
  17.    TrackBase = (struct TrackBase *)OpenLibrary("track.library",0) ;
  18.    if (!TrackBase) 
  19.       return ;
  20.    DOSBase = TrackBase -> tb_DOSBase ;
  21.  
  22.    VM_C = VM_Open("datafile") ;
  23.  
  24.    VM_L = VM_AllocMem(VM_C,1024) ;
  25.    VM_L2 = VM_AllocMem(VM_C,1024) ;
  26.    mem = VM_Lock(VM_L2) ;
  27.  
  28.    if (mem)
  29.       for(i=0;i<1024; i++) {
  30.          mem[i] = i & 0xff ;
  31.          }
  32.    else
  33.       Printf ("Lock failed\n") ;
  34.  
  35.    mem = VM_Lock(VM_L) ;
  36.  
  37.    if (mem)
  38.       for(i=0;i<1024; i++) {
  39.          mem[i] = i & 0xff ;
  40.          }
  41.    else
  42.       Printf ("Lock failed\n") ;
  43.  
  44.    VM_ReadOnly(VM_L) ;
  45.  
  46.    VM_UnLock(VM_L2) ;
  47.    VM_UnLock(VM_L) ;
  48.  
  49.    VM_Close(VM_C) ;
  50.  
  51.    CloseLibrary( (struct Library *) TrackBase ) ;
  52.    }
  53.