Changeset 341 for trunk/dll/autoview.c


Ignore:
Timestamp:
Jul 26, 2006, 3:58:56 AM (19 years ago)
Author:
root
Message:

Check more run time errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/autoview.c

    r291 r341  
    1414  23 May 05 SHL Use QWL_USER
    1515  29 May 06 SHL Sync with archiver.bb2 mods
     16  22 Jul 06 SHL Check more run time errors
    1617
    1718***********************************************************************/
     
    2122#define INCL_WIN
    2223#define INCL_GPI
    23 
    2424#include <os2.h>
     25
    2526#include <stdlib.h>
    2627#include <stdio.h>
    2728#include <string.h>
    2829#include <ctype.h>
     30
    2931#include "fm3dll.h"
    3032#include "fm3dlg.h"
     
    3335
    3436#pragma data_seg(DATA1)
     37
     38static PSZ pszSrcFile = __FILE__;
     39
    3540#pragma alloc_text(AUTOVIEW,AutoViewProc,CreateHexDump,AutoObjProc)
    3641#pragma alloc_text(AUTOVIEW2,MakeAutoWin,WriteEA,PutComments)
    3742
    38 static HWND hwndAutoObj = (HWND)0;
     43static HWND hwndAutoObj;
    3944static CHAR stopflag;
    4045static CHAR currfile[CCHMAXPATH];
    4146
    42 BOOL WriteEA (HWND hwnd,CHAR *filename,CHAR *eaname,USHORT type,CHAR *data) {
    43 
     47BOOL WriteEA (HWND hwnd,CHAR *filename,CHAR *eaname,USHORT type,CHAR *data)
     48{
    4449  /* save an ea to disk */
    4550
     
    8893  }
    8994
    90   if(!DosAllocMem((PPVOID)&pfealist,ealen,PAG_COMMIT | PAG_READ |
    91                   PAG_WRITE | OBJ_TILE) && pfealist) {
     95  rc = DosAllocMem((PPVOID)&pfealist,ealen,PAG_COMMIT | PAG_READ |
     96                   PAG_WRITE | OBJ_TILE);
     97  if (rc || !pfealist)
     98    Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
     99  else {
    92100    memset(pfealist,0,ealen);
    93101    pfealist->list[0].cbName = strlen(eaname);
     
    194202
    195203
    196 BOOL PutComments (HWND hwnd,CHAR *filename,CHAR *comments) {
    197 
     204BOOL PutComments (HWND hwnd,CHAR *filename,CHAR *comments)
     205{
    198206  register CHAR *p;
    199207
     
    272280MRESULT EXPENTRY AutoObjProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
    273281{
    274 
    275282  switch(msg) {
    276283    case UM_LOADFILE:
     
    304311                          0L)) {
    305312                ibufflen = (AutoviewHeight < 96) ? 512 : 3072;
    306                 ibuff = malloc(ibufflen + 2);
    307                 if(ibuff) {
     313                ibuff = xmalloc(ibufflen + 2,pszSrcFile,__LINE__);
     314                if (ibuff) {
    308315                  // Depends on CreateHexDump line width
    309316                  obufflen = (ibufflen / 16) * (6 + 3 * 16 + 1 + 16 + 1) + 80;
    310                   obuff = malloc(obufflen + 1);
    311                   if(obuff) {
     317                  obuff = xmalloc(obufflen + 1,pszSrcFile,__LINE__);
     318                  if (obuff) {
    312319                    *obuff = 0;
    313320                    if(!DosRead(handle,
     
    450457                }
    451458                bufflen = (CCHMAXPATHCOMP + 42) * nm;
    452                 buff = malloc(bufflen);
    453                 if(buff) {
     459                buff = xmalloc(bufflen,pszSrcFile,__LINE__);
     460                if (buff) {
    454461                  p = buff;
    455462                  *p = 0;
     
    518525            BOOL          readonly = FALSE;
    519526
    520             pgealist = malloc(sizeof(GEA2LIST) + 64);
    521             if(pgealist) {
    522               memset(pgealist,0,sizeof(GEA2LIST) + 64);
     527            pgealist = xmallocz(sizeof(GEA2LIST) + 64,pszSrcFile,__LINE__);
     528            if (pgealist) {
    523529              pgea = &pgealist->list[0];
    524530              strcpy(pgea->szName,".COMMENTS");
     
    526532              pgea->oNextEntryOffset = 0L;
    527533              pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
    528               pfealist = malloc(65536);
    529               if(pfealist) {
    530                 memset(pfealist,0,65536);
     534              pfealist = xmallocz(65536,pszSrcFile,__LINE__);
     535              if (pfealist) {
    531536                pfealist->cbList = 65536;
    532537                eaop.fpGEA2List = pgealist;
     
    543548                    value[pfea->cbValue] = 0;
    544549                    if(*(USHORT *)value == EAT_MVMT) {
    545                       buff = malloc(65536);
    546                       if(buff) {
     550                      buff = xmalloc(65536,pszSrcFile,__LINE__);
     551                      if (buff) {
    547552                        p = buff;
    548553                        *buff = 0;
     
    619624
    620625
    621 VOID MakeAutoWin (VOID *args) {
    622 
     626VOID MakeAutoWin (VOID *args)
     627{
    623628  HAB         hab2;
    624629  HMQ         hmq2;
     
    669674
    670675
    671 MRESULT EXPENTRY AutoViewProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    672 
     676MRESULT EXPENTRY AutoViewProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     677{
    673678  USHORT id = WinQueryWindowUShort(hwnd,QWS_ID);
    674679
     
    678683        MRESULT mr;
    679684
    680         if(!hwndAutoObj &&
    681            _beginthread(MakeAutoWin,
    682                         NULL,
    683                         65536,
    684                         (PVOID)hwnd) == -1)
    685           PostMsg(hwnd,
    686                   UM_CLOSE,
    687                   MPVOID,
    688                   MPVOID);
     685        if (!hwndAutoObj) {
     686          if (_beginthread(MakeAutoWin,NULL,65536,(PVOID)hwnd) == -1) {
     687            Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     688            PostMsg(hwnd,
     689                    UM_CLOSE,
     690                    MPVOID,
     691                    MPVOID);
     692          }
     693        }
    689694        mr = PFNWPStatic(hwnd,msg,mp1,mp2);
    690695        SetPresParams(hwnd,
     
    791796            if(*currfile) {
    792797              if(MLEgetchanged(hwnd)) {
    793 
    794                 CHAR *ea = malloc(32768);
    795 
    796                 if(ea) {
     798                CHAR *ea = xmalloc(32768,pszSrcFile,__LINE__);
     799                if (ea) {
    797800                  *ea = 0;
    798801                  WinQueryWindowText(hwnd,32767,ea);
     
    863866          if(*currfile) {
    864867
    865             CHAR *cf = strdup(currfile);
    866 
    867             if(cf) {
     868            CHAR *cf = xstrdup(currfile,pszSrcFile,__LINE__);
     869
     870            if (cf) {
    868871              stopflag++;
    869872              if(!PostMsg(hwndAutoObj,
     
    10031006  return PFNWPStatic(hwnd,msg,mp1,mp2);
    10041007}
    1005 
Note: See TracChangeset for help on using the changeset viewer.