Changeset 329 for trunk/dll/tools.c


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

Check more run time errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.