Changeset 329


Ignore:
Timestamp:
Jul 25, 2006, 8:39:11 PM (19 years ago)
Author:
root
Message:

Check more run time errors

Location:
trunk/dll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/timer.c

    r2 r329  
     1
     2/***********************************************************************
     3
     4  $Id$
     5
     6  Timer thread
     7
     8  Copyright (c) 1993-98 M. Kimes
     9  Copyright (c) 2006 Steven H. Levine
     10
     11  22 Jul 06 SHL Check more run time errors
     12
     13***********************************************************************/
     14
    115#define INCL_DOS
    216#define INCL_DOSERRORS
    317#define INCL_WIN
     18#include <os2.h>
    419
    5 #include <os2.h>
    620#include <stdarg.h>
    721#include <stdio.h>
    822#include <stdlib.h>
    923#include <string.h>
     24
    1025#include "fm3dll.h"
    1126#include "fm3str.h"
     
    1328#pragma alloc_text(TIMER,TimerThread,StartTimer,StopTimer)
    1429
     30static PSZ pszSrcFile = __FILE__;
     31
    1532static HEV hevTimerSem;
    1633
    17 
    18 static void TimerThread (void *args) {
    19 
     34static void TimerThread (void *args)
     35{
    2036  HAB   hab2;
    2137  HMQ   hmq2;
     
    6682}
    6783
    68 BOOL StartTimer (void) {
     84//== StartTimer() return TRUE can start thread ==
    6985
    70   return (_beginthread(TimerThread,
    71                        NULL,
    72                        32768,
    73                        (PVOID)0) != -1);
     86BOOL StartTimer (void)
     87{
     88  INT rc = _beginthread(TimerThread,NULL,32768,(PVOID)0);
     89
     90  if (rc == -1)
     91    Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     92
     93  return rc != -1;
    7494}
    7595
    76 void StopTimer (void) {
    77 
     96void StopTimer (void)
     97{
    7898  DosPostEventSem(hevTimerSem);
    7999}
  • trunk/dll/tools.c

    r130 r329  
    44  $Id$
    55
    6   Toolbar support routines for FM/2
     6  Toolbar support routines
    77
    88  Copyright (c) 1994-97 M. Kimes
    9   Copyright (c) 2004, 2005 Steven H.Levine
     9  Copyright (c) 2004, 2006 Steven H.Levine
    1010
    1111  01 Aug 04 SHL Rework lstrip/rstrip usage
    1212  23 May 05 SHL Use QWL_USER
     13  22 Jul 06 SHL Check more run time errors
    1314
    1415***********************************************************************/
     
    1617#define INCL_DOS
    1718#define INCL_WIN
    18 
    1919#include <os2.h>
     20
    2021#include <stdio.h>
    2122#include <stdlib.h>
    2223#include <string.h>
    2324#include <share.h>
     25
    2426#include "fm3dll.h"
    2527#include "fm3dlg.h"
     
    2830
    2931#pragma data_seg(DATA1)
     32
     33static PSZ pszSrcFile = __FILE__;
     34
    3035#pragma alloc_text(TOOLS,load_tools,save_tools,add_tool,insert_tool,del_tool,free_tools,swap_tools,load_quicktools,save_quicktools)
    3136#pragma alloc_text(TOOLS1,ReOrderToolsProc,PickToolProc,AddToolProc,ToolIODlgProc)
     
    5661  strcat(s,"QUICKTLS.DAT");
    5762  fp = _fsopen(s,"r",SH_DENYWR);
    58   if(fp) {
     63  if (fp) {
    5964    while(x < 50 && !feof(fp)) {
    6065      if(!fgets(s,CCHMAXPATH + 2,fp))
     
    6368      bstripcr(s);
    6469      if(*s && *s != ';') {
    65         quicktool[x] = strdup(s);
     70        quicktool[x] = xstrdup(s,pszSrcFile,__LINE__);
    6671        if(quicktool[x])
    6772          x++;
     
    8590    strcat(s,"\\");
    8691  strcat(s,"QUICKTLS.DAT");
    87   fp = fopen(s,"w");
    88   if(fp) {
     92  fp = xfopen(s,"w",pszSrcFile,__LINE__);
     93  if (fp) {
    8994    for(x = 0;quicktool[x] && x < 50;x++)
    9095      fprintf(fp,"%s\n",quicktool[x]);
     
    117122    strcpy(lasttoolbox,filename);
    118123    fp = _fsopen(filename,"r",SH_DENYWR);
    119     if(fp) {
     124    if (fp) {
    120125      toolhead = free_tools();
    121126      while(!feof(fp)) {
     
    134139        if(!(USHORT)atoi(idstr))
    135140          continue;
    136         info = malloc(sizeof(TOOL));
    137         if(info) {
    138           memset(info,0,sizeof(TOOL));
     141        info = xmallocz(sizeof(TOOL),pszSrcFile,__LINE__);
     142        if (info) {
    139143          if(*help) {
    140144            literal(help);
    141145            if(*help)
    142               info->help = strdup(help);
     146              info->help = xstrdup(help,pszSrcFile,__LINE__);
    143147          }
    144148          if(*text)
    145             info->text = strdup(text);
     149            info->text = xstrdup(text,pszSrcFile,__LINE__);
    146150          info->flags = (atoi(flagstr) & (~(T_TEXT | T_EMPHASIZED)));
    147151          info->id = (USHORT)atoi(idstr);
     
    193197    return;
    194198  }
    195   fp = fopen(filename,"w");
    196   if(fp) {
     199  fp = xfopen(filename,"w",pszSrcFile,__LINE__);
     200  if (fp) {
    197201    fprintf(fp,GetPString(IDS_TOOLFILETEXT),filename);
    198202    info = toolhead;
     
    777781              tool->text = NULL;
    778782              if(*help)
    779                 tool->help = strdup(help);
     783                tool->help = xstrdup(help,pszSrcFile,__LINE__);
    780784              if(*text)
    781                 tool->text = strdup(text);
     785                tool->text = xstrdup(text,pszSrcFile,__LINE__);
    782786              tool->flags = (((dropable) ? T_DROPABLE : 0)  |
    783787                            ((invisible) ? T_INVISIBLE : 0) |
     
    811815              tool = tool->next;
    812816            }
    813             tool = malloc(sizeof(TOOL));
    814             if(tool) {
    815               memset(tool,0,sizeof(TOOL));
     817            tool = xmallocz(sizeof(TOOL),pszSrcFile,__LINE__);
     818            if (tool) {
    816819              if(*help)
    817                 tool->help = strdup(help);
     820                tool->help = xstrdup(help,pszSrcFile,__LINE__);
    818821              if(*text)
    819                 tool->text = strdup(text);
     822                tool->text = xstrdup(text,pszSrcFile,__LINE__);
    820823              tool->id = (USHORT)atoi(idstr);
    821824              tool->flags = (((dropable) ? T_DROPABLE : 0)  |
Note: See TracChangeset for help on using the changeset viewer.