当前位置: 首页>>代码示例>>C++>>正文


C++ DosFreeMem函数代码示例

本文整理汇总了C++中DosFreeMem函数的典型用法代码示例。如果您正苦于以下问题:C++ DosFreeMem函数的具体用法?C++ DosFreeMem怎么用?C++ DosFreeMem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DosFreeMem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SysPutEA

unsigned long SysPutEA(unsigned char *name,
                           unsigned long numargs,
                           RXSTRING args[],
                           char *queuename,
                           RXSTRING *retstr)
{
    unsigned long rc;                      /* Ret code                   */
    unsigned long act;                     /* open action                */
    void          *fealist;                /* fealist buffer             */
    EAOP2         eaop;                    /* eaop structure             */
    PFEA2         pfea;                    /* pfea structure             */
    HFILE         handle;                  /* file handle                */



    if (numargs != 3 || !RXVALIDSTRING(args[0]) || !RXVALIDSTRING(args[1]))
            return INVALID_ROUTINE;

    if (rc = DosOpen2(args[0].strptr, &handle, &act,
                      0L, 0, OPEN_ACTION_OPEN_IF_EXISTS,
                      OPEN_ACCESS_READWRITE + OPEN_SHARE_DENYWRITE +
                      OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH,
                      NULL)) {
        RETVAL(rc)
    }

    if (DosAllocMem((PPVOID)&fealist, 0x00010000L, AllocFlag)) {
        BUILDRXSTRING(retstr, ERROR_NOMEM);
        return VALID_ROUTINE;
    }

    eaop.fpFEA2List = (PFEA2LIST)fealist;/* Set memory for the FEA     */
    eaop.fpGEA2List = NULL;              /* GEA is unused              */
    pfea = &eaop.fpFEA2List->list[0];    /* point to first FEA         */
    pfea->fEA = '\0';                    /* set the flags              */
                                         /* Size of FEA name field     */
    pfea->cbName = (BYTE)args[1].strlength;
                                         /* Size of Value for this one */
    pfea->cbValue = (SHORT)args[2].strlength;
                                         /* Set the name of this FEA   */
    strcpy((PSZ)pfea->szName, args[1].strptr);
                                         /* Set the EA value           */
    memcpy((PSZ)pfea->szName+(pfea->cbName+1), args[2].strptr,
        args[2].strlength);
    pfea->oNextEntryOffset = 0;          /* no next entry              */
    eaop.fpFEA2List->cbList =            /* Set the total size var     */
        sizeof(ULONG) + sizeof(FEA2) + pfea->cbName + pfea->cbValue;

                                         /* set the file info          */
    rc = DosSetFileInfo(handle, 2, (PSZ)&eaop, sizeof(EAOP2));
    DosClose(handle);                    /* Close the File             */
    DosFreeMem(fealist);                 /* Free the memory            */

    RETVAL(rc)
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:55,代码来源:syseautil.c

示例2: test3

static void test3( void )
{
    printf("***** Test3: Copy to source memory which is destination memory "
           "of other source memory...\n");

    static const char *p1Str = "6789067890";
    static const char *p2Str = "1234512345";
    static const char *p3Str = "1234567890";

    char *p1;
    char *p2;
    char *p3;

    DosAllocMem(( PPVOID )&p1, ALLOC_SIZE, fPERM | PAG_COMMIT );

    strcpy( p1, p3Str);
    p2 = copyOnWrite( p1, COPY_SIZE );
    p3 = copyOnWrite( p2, COPY_SIZE );

    printf("p1 = %p, p2 = %p, p3 = %p\n", p1, p2, p3 );
    printf("p1 = [%s], p2 = [%s], p3 = [%s]\n", p1, p2, p3 );

    printf("Copying %.5s to ( p2 + 5 )\n", p2Str );
    memcpy( p2 + 5, p2Str, 5 );

    printf("Copying %.5s to p1\n", p1 + 5 );
    memcpy( p1, p1 + 5, 5 );

    printf("p1 = [%s], p2 = [%s], p3 = [%s]\n", p1, p2, p3 );

    fprintf( stderr, "Test3: ");
    if( memcmp( p1, p1Str, strlen( p1Str ))
        || memcmp( p2, p2Str, strlen( p2Str ))
        || memcmp( p3, p3Str, strlen( p3Str )))
        fprintf( stderr, "Failed\n");
    else
        fprintf( stderr, "Succeeded\n");

    DosFreeMem( p3 );
    DosFreeMem( p2 );
    DosFreeMem( p1 );
}
开发者ID:komh,项目名称:os2codes,代码行数:42,代码来源:copyonwrite-test.c

示例3: usalo_freebuf

static void
usalo_freebuf(SCSI *usalp)
{
	if (usalp->bufbase && DosFreeMem(usalp->bufbase)) {
		fprintf((FILE *)usalp->errfile,
		"Cannot free buffer memory for ASPI-Router!\n"); /* Free our memory buffer if not already done */
	}
	if (buffer == usalp->bufbase)
		buffer = NULL;
	usalp->bufbase = NULL;
}
开发者ID:Distrotech,项目名称:cdrkit,代码行数:11,代码来源:scsi-os2.c

示例4: _MD_MemUnmap

PRStatus _MD_MemUnmap(void *addr, PRUint32 len)
{
    PRUint32 rv;

    /* we just have to trust that addr & len are those used by MemMap */
    rv = DosFreeMem(addr);
    if (rv) {
        PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv);
        return PR_FAILURE;
    }
    return PR_SUCCESS;
}
开发者ID:ppbao,项目名称:mozilla-os2,代码行数:12,代码来源:os2misc.c

示例5: main

void main(void) {
        initFileTable();
        initProcess(0,0);
        initMemory();
        
        APIRET rc;
        PVOID pv;
        rc = DosAllocSharedMem(&pv, "\\SHAREMEM\\Ivan", 8192, PAG_COMMIT|PAG_READ|PAG_WRITE);
        if(rc==0)
                rc = DosFreeMem(pv);
        printf("rc=%d\n",rc);
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:12,代码来源:test.cpp

示例6: FreeRxString

// FreeRxString -- Free a REXX string.
//
//      Return: none
//
void FreeRxString(
    PRXSTRING rxString)
{
    if (
        rxString != NULL &&
        rxString->strptr != NULL)
    {
        DosFreeMem(rxString->strptr);
        rxString->strptr = NULL;
        rxString->strlength = 0;
    }
}
开发者ID:OS2World,项目名称:LIB-REXX-RexxIPC,代码行数:16,代码来源:rxapiutl.c

示例7: ReadConfigFile

int ReadConfigFile(HWND hwnd, char szFileSpec[],char **ppBuffer)
  {
  ULONG ulStatus;
  HFILE hFile;
  FILESTATUS3 stFileInfo;
  int iCount;
  char szMessage[CCHMAXPATH];
  APIRET rc;

  if ((rc = DosOpen(szFileSpec,&hFile,&ulStatus,0L,0,1,0x0022,(PEAOP2)0L)) != 0)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szMessage,"Could not open %s - Error = %u",szFileSpec,rc);
      MessageBox(HWND_DESKTOP,szMessage);
      }
    return(0);
    }
  DosQueryFileInfo(hFile,1,&stFileInfo,sizeof(FILESTATUS3));
  iCount = stFileInfo.cbFile;
  if ((rc = DosAllocMem((PVOID)ppBuffer,(iCount + 10),(PAG_COMMIT | PAG_READ | PAG_WRITE))) != NO_ERROR)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szMessage,"Unable to Allocate memory to read %s - %u",szFileSpec,rc);
      MessageBox(HWND_DESKTOP,szMessage);
      }
    iCount = 0;
    }
  if (DosRead(hFile,(PVOID)*ppBuffer,iCount,(ULONG *)&iCount) != 0)
    {
    DosFreeMem(*ppBuffer);
    iCount = 0;
    }
  else
    {
    /*
    ** ignore/remove EOF character, if present
    */
    if ((*ppBuffer)[(iCount) - 1] == '\x1a')
      iCount--;
    /*
    **  Add LF and CR to end of file, if not already there
    */
    if ((*ppBuffer)[iCount - 1] != '\x0a')
      {
      (*ppBuffer)[(iCount)++] = '\x0d';
      (*ppBuffer)[(iCount)++] = '\x0a';
      }
    }
  DosClose(hFile);
  return(iCount);
  }
开发者ID:OS2World,项目名称:APP-COMM-ComScope,代码行数:53,代码来源:cfg_sys.c

示例8: MemHeapTerm

BOOL MemHeapTerm(VOID)
  {
  if ( hp )
    {
    return !(_uclose(hp) ||
             _udestroy(hp, _FORCE) ||
             DosSubUnsetMem(pbasemem) ||
             DosFreeMem(pbasemem));
    } /* endif */
  closeLogFile();
  return FALSE;
  }
开发者ID:OS2World,项目名称:UTIL-FILE-DataSeeker,代码行数:12,代码来源:memmgr.c

示例9: Clipper_RestoreClipboard

VOID Clipper_RestoreClipboard( VOID )
{
 // Переносим в Clipboard предыдущие данные.
 CHAR Mozilla_internal_format[] = "text/unicode";

 PutStringIntoClipboard( Enhancer.Application,
                         Clipper.RTSettings.Clipboard_data_Text,
                         Clipper.RTSettings.Clipboard_data_UCS2,
                         Clipper.RTSettings.Clipboard_data_UCS2_length,
                         Mozilla_internal_format );

 // Освобождаем память.
 if( Clipper.RTSettings.Clipboard_data_Text != NULL ) { DosFreeMem( Clipper.RTSettings.Clipboard_data_Text ); Clipper.RTSettings.Clipboard_data_Text = NULL; }
 if( Clipper.RTSettings.Clipboard_data_UCS2 != NULL ) { DosFreeMem( Clipper.RTSettings.Clipboard_data_UCS2 ); Clipper.RTSettings.Clipboard_data_UCS2 = NULL; }

 Clipper.RTSettings.Clipboard_data_Text_length = 0;
 Clipper.RTSettings.Clipboard_data_UCS2_length = 0;

 // Возврат.
 return;
}
开发者ID:OS2World,项目名称:UTIL-WPS-Nice_OS2_Enhancer,代码行数:21,代码来源:Clipper_code.cpp

示例10: _MD_MemMap

void * _MD_MemMap(PRFileMap *fmap, PROffset64 offset, PRUint32 len)
{
    PRUint32 rv;
    void *addr;

    /* prevent mappings beyond EOF + remainder of page */
    if (offset + len > fmap->md.maxExtent) {
        PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
        return NULL;
    }
    if (PR_Seek64(fmap->fd, offset, PR_SEEK_SET) == -1) {
        return NULL;
    }
    /* try for high memory, fall back to low memory if hi-mem fails */
#if defined(MOZ_OS2_HIGH_MEMORY)
    rv = DosAllocMem(&addr, len, OBJ_ANY | PAG_COMMIT | PAG_READ | PAG_WRITE);
    if (rv)
#endif
    {
        rv = DosAllocMem(&addr, len, PAG_COMMIT | PAG_READ | PAG_WRITE);
        if (rv) {
            PR_SetError(PR_OUT_OF_MEMORY_ERROR, rv);
            return NULL;
        }
    }
    if (PR_Read(fmap->fd, addr, len) == -1) {
        DosFreeMem(addr);
        return NULL;
    }
    /* don't permit writes if readonly */
    if (fmap->prot == PR_PROT_READONLY) {
        rv = DosSetMem(addr, len, PAG_READ);
        if (rv) {
            DosFreeMem(addr);
            PR_SetError(PR_UNKNOWN_ERROR, rv);
            return NULL;
        }
    }
    return addr;
}
开发者ID:ppbao,项目名称:mozilla-os2,代码行数:40,代码来源:os2misc.c

示例11: helpProc

MRESULT EXPENTRY helpProc( HWND hwndDlg, ULONG msg,
			    MPARAM mp1, MPARAM mp2 )
{
LONG bytes;
IPT ipt;

switch ( msg )
   {
   case WM_INITDLG:
      WinSendMsg (WinWindowFromID(hwndDlg, ID_HELPENTRY),
		  MLM_SETTEXTLIMIT,
		  MPFROMLONG (30000L), (MPARAM) 0L);
      WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY),
		 MLM_SETTEXTCOLOR,
		 MPFROMLONG (CLR_DARKBLUE), 0L);
      WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY),
		 MLM_SETBACKCOLOR,
		 MPFROMLONG (CLR_WHITE), 0L);
      bytes = loadFile("DataPad.DOC");
      if( bytes <= 0 )
	 {
	 DosFreeMem(iobuf);
	 WinDismissDlg( hwndDlg, TRUE );
	 }
      WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY),
		 MLM_SETIMPORTEXPORT,
		 (MPARAM) iobuf,
		 MPFROMLONG(bytes));
      ipt = -1;
      WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY),
		 MLM_IMPORT,
		 (MPARAM)&ipt,
		 MPFROMLONG(bytes));
      DosFreeMem(iobuf);
      return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );

   default :
      return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
   }
}
开发者ID:OS2World,项目名称:APP-DATABASE-Datapad,代码行数:40,代码来源:about.c

示例12: test6

static void test6( void )
{
    printf("***** Test6: Decommit source memory...\n");

    static const char *p2Str = "6789067890";
    static const char *p3Str = "1234567890";

    char *p1;
    char *p2;
    char *p3;

    DosAllocMem(( PPVOID )&p1, ALLOC_SIZE, fPERM | PAG_COMMIT );

    strcpy( p1, p3Str);
    p2 = copyOnWrite( p1, COPY_SIZE );
    p3 = copyOnWrite( p2, COPY_SIZE );

    printf("p1 = %p, p2 = %p, p3 = %p\n", p1, p2, p3 );
    printf("p1 = [%s], p2 = [%s], p3 = [%s]\n", p1, p2, p3 );

    printf("Decommiting p1\n");
    printf("DosSetMem( p1 ) = %ld\n",
           DosSetMem( p1, ALLOC_SIZE, PAG_DECOMMIT ));

    printf("Copying %.5s to p2\n", p2 + 5 );
    memcpy( p2, p2 + 5, 5 );

    printf("p2 = [%s], p3 = [%s]\n", p2, p3 );

    fprintf( stderr, "Test6: ");
    if( memcmp( p2, p2Str, strlen( p2Str ))
        || memcmp( p3, p3Str, strlen( p3Str )))
        fprintf( stderr, "Failed\n");
    else
        fprintf( stderr, "Succeeded\n");

    DosFreeMem( p3 );
    DosFreeMem( p2 );
    DosFreeMem( p1 );
}
开发者ID:komh,项目名称:os2codes,代码行数:40,代码来源:copyonwrite-test.c

示例13: CBZSave

//save current settings to the given ini file
BOOL CBZSave(HINI hIni, char szClass[], PVOID pData, char szCustomName[])
{
    PLUGINSHARE *pPluginShare;
    char szShareName[32];
    char szSaveName[128];

    pPluginShare = (PLUGINSHARE *) pData;
    //if null, this is a default apply, so load shared memory.
    if (pPluginShare == NULL)
    {
        strcpy(szShareName, PLUGIN_SHARE);
        strcat(szShareName, szClass);

        // if shared mem is not available, try allocating temporary space!
        if (DosGetNamedSharedMem((PPVOID) & pPluginShare, szShareName, PAG_READ | PAG_WRITE) != NO_ERROR)
        {
            //try Allocating temporary space for the plugin data so we can write to the ini file
            if (DosAllocMem((PPVOID) & pPluginShare,
                            sizeof(PLUGINSHARE),
                            PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
                return (FALSE);     //No Good... can't save.

        }

        //write pPluginShare to the ini file!
        strcpy(szSaveName, szClass);
        strcat(szSaveName, "_CBZLINESPlugin");
        PrfWriteProfileData(hIni,
                            "UserOptionsData",
                            szSaveName,
                            pPluginShare,
                            sizeof(PLUGINSHARE));

        DosFreeMem(pPluginShare);
    }
    else
    {
        strcpy(szSaveName, szCustomName);
        strcat(szSaveName, "_");
        strcat(szSaveName, szClass);
        strcat(szSaveName, "_CBZLINESPlugin");

        PrfWriteProfileData(hIni,
                            "CustomOptionsData",
                            szSaveName,
                            pPluginShare,
                            sizeof(PLUGINSHARE));

    }

    return (TRUE);
}
开发者ID:OS2World,项目名称:UTIL-WPS-CandyBarz,代码行数:53,代码来源:plugin.c

示例14: load

/*@ XBitmap :: ReleaseFilterStruct (XBitmapFilter * params)
@group loading/saving a bitmap
@remarks Released bitmap-filters created by XBitmap :: GetImportFilter/GetExportFilter and XGLibFileDialog
@parameters    <t 'ø' c=2>
               øchar * filename           øfilename of the file to load (later)
               <\t>
@exceptions   If the method fails to create a new bitmap an exception of the type XException is thrown.
*/
void XBitmap :: ReleaseFilterStruct (XBitmapFilter * params) {
   int n;
   if(params)
   {
   if (BFT_TIFF == params->cFilterID)
      for (n = 0; n < BFP_TIFF_TAGCOUNT; n++) {
         free (((XTIFFExportFilter*) params)->pszTagValue [n]);
         ((XTIFFExportFilter*) params)->pszTagValue [n] = NULL;
      }
   DosFreeMem (params);
   } /* end if */
   params = NULL;
}
开发者ID:OS2World,项目名称:LIB-Open_Object_Library,代码行数:21,代码来源:xgraphob.cpp

示例15: return

char *PSBMLoadBitmapFile( char *pszFileName, GBM *pgbm, GBMRGB *pgbmrgb )
{
    HFILE   hBMPFile;
    ULONG   ulNewFile;
    ULONG   ulStride;
    ULONG   cbData;
    char    *pchData;

    if( DosOpen(    pszFileName,
                    &hBMPFile,
                    &ulNewFile,
                    0L,
                    FILE_NORMAL,
                    OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
                    OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY,
                    NULL ) != 0L )
    {
        return( NULL );
    }

    if( GBMReadBMPHeader( hBMPFile, pgbm ) != TRUE )        // read bmp header
    {
        DosClose( hBMPFile );
        return( NULL );
    }

    if( GBMReadPalette( hBMPFile, pgbm, pgbmrgb ) != TRUE )  // read bmp palette
    {
        DosClose( hBMPFile );
        return( NULL );
    }

    ulStride = ( ( pgbm->w * pgbm->bpp + 31 ) / 32 ) * 4;     // calculate size of data and alloc it
    cbData = pgbm->h * ulStride;
    if( DosAllocMem( ( PPVOID )&pchData, cbData, PAG_READ | PAG_WRITE | PAG_COMMIT ) != 0 )
    {
        DosClose( hBMPFile );
        return( NULL );
    }

    if( GBMReadData( hBMPFile, pgbm, pchData ) != TRUE )        // read it in
    {
        DosFreeMem( pchData );
        DosClose( hBMPFile );
        return( NULL );
    }

    DosClose( hBMPFile );

    return( pchData );
}
开发者ID:OS2World,项目名称:UTIL-WPS-CandyBarz,代码行数:51,代码来源:psBitmap.c


注:本文中的DosFreeMem函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。