fix: cfree

This commit is contained in:
kuoi 2023-04-11 23:34:31 +08:00
parent b2951105ae
commit a80e729e21
6 changed files with 91 additions and 121 deletions

View file

@ -426,7 +426,7 @@ SetNADData()
Fills in the display data structure for an initial monochrome display. Fills in the display data structure for an initial monochrome display.
All settings are simple defaults, and will need to be modified externally All settings are simple defaults, and will need to be modified externally
if otherwise. This routine passes back a new NA_DisplayData structure, which if otherwise. This routine passes back a new NA_DisplayData structure, which
can be destroyed after use with a call to cfree(). can be destroyed after use with a call to free().
Copyright (c) 1989-1990, University of Illinois board of trustees. All Copyright (c) 1989-1990, University of Illinois board of trustees. All
rights reserved. Written by Steven Smith at the Center for Prokaryote Genome rights reserved. Written by Steven Smith at the Center for Prokaryote Genome

View file

@ -342,7 +342,7 @@ Notify_arg arg;
repeat_cnt = 0; repeat_cnt = 0;
SetNACursor(ddata,EditCan,win,xwin,dpy,gc); SetNACursor(ddata,EditCan,win,xwin,dpy,gc);
cfree(buf); free(buf);
} }
/* /*
* Check mode * Check mode

View file

@ -410,7 +410,7 @@ DO()
xv_set(pframe,FRAME_BUSY,TRUE,0); xv_set(pframe,FRAME_BUSY,TRUE,0);
xv_set(frame,FRAME_BUSY,TRUE,0); xv_set(frame,FRAME_BUSY,TRUE,0);
system(Action); system(Action);
cfree(Action); free(Action);
xv_set(pframe,FRAME_BUSY,FALSE,0); xv_set(pframe,FRAME_BUSY,FALSE,0);
xv_set(frame,FRAME_BUSY,FALSE,0); xv_set(frame,FRAME_BUSY,FALSE,0);
BlockInput = FALSE; BlockInput = FALSE;
@ -503,7 +503,7 @@ GfileFormat file;
strncat(temp,Action,i); strncat(temp,Action,i);
strncat(temp,method,strlen(method)); strncat(temp,method,strlen(method));
strcat( temp,&(Action[i+strlen(symbol)]) ); strcat( temp,&(Action[i+strlen(symbol)]) );
cfree(Action); free(Action);
Action = temp; Action = temp;
} }
return(Action); return(Action);
@ -592,7 +592,7 @@ GmenuItemArg arg;
strncat(temp,Action,i-1); strncat(temp,Action,i-1);
strncat(temp,textvalue,strlen(textvalue)); strncat(temp,textvalue,strlen(textvalue));
strcat( temp,&(Action[i+strlen(symbol)]) ); strcat( temp,&(Action[i+strlen(symbol)]) );
cfree(Action); free(Action);
Action = temp; Action = temp;
} }
else else
@ -605,7 +605,7 @@ GmenuItemArg arg;
strncat(temp,Action,i); strncat(temp,Action,i);
strncat(temp,method,strlen(method)); strncat(temp,method,strlen(method));
strcat( temp,&(Action[i+strlen(symbol)]) ); strcat( temp,&(Action[i+strlen(symbol)]) );
cfree(Action); free(Action);
Action = temp; Action = temp;
} }
} }

View file

@ -182,10 +182,10 @@ char* block;
FileIO.c: In function `Cfree': FileIO.c: In function `Cfree':
FileIO.c:181: void value not ignored as it ought to be FileIO.c:181: void value not ignored as it ought to be
if(cfree(block) == 0) if(free(block) == 0)
Warning("Error in Cfree..."); Warning("Error in Cfree...");
*/ */
cfree(block); free(block);
} }
else else
Warning("Error in Cfree, NULL block"); Warning("Error in Cfree, NULL block");

View file

@ -751,7 +751,7 @@ NA_Alignment *aln;
if (this->description[0]) if (this->description[0])
strcpy(that->description, this->description); strcpy(that->description, this->description);
if (this->sequence) { if (this->sequence) {
cfree(that->sequence); free(that->sequence);
that->sequence = this->sequence; that->sequence = this->sequence;
that->seqlen = this->seqlen; that->seqlen = this->seqlen;
that->seqmaxlen = this->seqmaxlen; that->seqmaxlen = this->seqmaxlen;
@ -783,7 +783,7 @@ NA_Alignment *aln;
that->comments_maxlen); that->comments_maxlen);
} }
if (this->cmask) { if (this->cmask) {
cfree(that->cmask); free(that->cmask);
that->cmask = this->cmask; that->cmask = this->cmask;
} }
if (this->offset != that->offset) that->offset = this->offset; if (this->offset != that->offset) that->offset = this->offset;

View file

@ -1,14 +1,15 @@
#include <malloc.h>
#include <pixrect/pixrect.h>
#include <stdio.h> #include <stdio.h>
#include <xview/defaults.h> #include <xview/defaults.h>
#include <xview/xview.h> #include <xview/icon.h>
#include <xview/panel.h> #include <xview/panel.h>
#include <xview/window.h> #include <xview/window.h>
#include <xview/icon.h> #include <xview/xview.h>
#include <pixrect/pixrect.h>
#include <malloc.h>
#include "menudefs.h"
#include "defines.h" #include "defines.h"
#include "globals.h" #include "globals.h"
#include "menudefs.h"
/* /*
Main() Main()
@ -25,7 +26,8 @@ All rights reserved.
*/ */
Gmenu menu[100]; Gmenu menu[100];
int num_menus = 0,repeat_cnt = 0; // int num_menus = 0;
int repeat_cnt = 0;
Frame frame, pframe, infoframe; Frame frame, pframe, infoframe;
Panel popup, infopanel; Panel popup, infopanel;
Panel_item left_foot, right_foot; Panel_item left_foot, right_foot;
@ -41,18 +43,15 @@ int TextClipSize = 0,TextClipLength = 0;
* Icon structure (pixmap dependent) * Icon structure (pixmap dependent)
*/ */
static short GDEicon[258] = { static short GDEicon[258] = {
#include "icon_gde" #include "icon_gde"
}; };
mpr_static(iconpr, 64, 64, 1, GDEicon); mpr_static(iconpr, 64, 64, 1, GDEicon);
main(argc,argv) main(argc, argv) int argc;
int argc;
char **argv; char **argv;
{ {
Icon tool_icon; /* obvious */ Icon tool_icon; /* obvious */
extern char FileName[], current_dir[]; extern char FileName[], current_dir[];
@ -70,52 +69,34 @@ char **argv;
*/ */
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0); xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
/* /*
* Main frame (primary window); * Main frame (primary window);
*/ */
frame = xv_create((int) NULL,FRAME, frame = xv_create((int)NULL, FRAME, FRAME_NO_CONFIRM, FALSE,
FRAME_NO_CONFIRM,FALSE,
FRAME_LABEL, "Genetic Data Environment 2.2", FRAME_LABEL, "Genetic Data Environment 2.2",
FRAME_INHERIT_COLORS,TRUE, FRAME_INHERIT_COLORS, TRUE, XV_WIDTH, 700, XV_HEIGHT,
XV_WIDTH,700, 500, FRAME_SHOW_FOOTER, TRUE, 0);
XV_HEIGHT,500,
FRAME_SHOW_FOOTER,TRUE,
0);
/* /*
* Popup frame (dialog box window), and default settings in * Popup frame (dialog box window), and default settings in
* the dialog box. These are changed to fit each individual * the dialog box. These are changed to fit each individual
* command's needs in EventHandler(). * command's needs in EventHandler().
*/ */
infoframe = xv_create(frame,FRAME_CMD, infoframe =
FRAME_LABEL,"Messages", xv_create(frame, FRAME_CMD, FRAME_LABEL, "Messages",
WIN_DESIRED_HEIGHT,100, WIN_DESIRED_HEIGHT, 100, WIN_DESIRED_WIDTH, 300,
WIN_DESIRED_WIDTH,300, FRAME_SHOW_RESIZE_CORNER, TRUE, FRAME_INHERIT_COLORS,
FRAME_SHOW_RESIZE_CORNER,TRUE, TRUE, FRAME_CLOSED, FALSE, WIN_SHOW, FALSE, 0);
FRAME_INHERIT_COLORS,TRUE,
FRAME_CLOSED,FALSE,
WIN_SHOW,FALSE,
0);
pframe = xv_create(frame,FRAME_CMD, pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE,
FRAME_CMD_PUSHPIN_IN,TRUE, FRAME_DONE_PROC, FrameDone, XV_HEIGHT, 100, XV_WIDTH,
FRAME_DONE_PROC,FrameDone, 300, FRAME_SHOW_RESIZE_CORNER, FALSE, FRAME_CLOSED,
XV_HEIGHT,100, FALSE, XV_X, 300, XV_Y, 150, WIN_SHOW, FALSE, 0);
XV_WIDTH,300,
FRAME_SHOW_RESIZE_CORNER,FALSE,
FRAME_CLOSED,FALSE,
XV_X,300,
XV_Y,150,
WIN_SHOW,FALSE,
0);
infopanel = xv_get(infoframe, FRAME_CMD_PANEL); infopanel = xv_get(infoframe, FRAME_CMD_PANEL);
xv_set(infopanel, PANEL_LAYOUT,PANEL_VERTICAL, xv_set(infopanel, PANEL_LAYOUT, PANEL_VERTICAL, XV_WIDTH, 300,
XV_WIDTH,300, XV_HEIGHT, 50, 0);
XV_HEIGHT,50,
0);
left_foot = xv_create(infopanel, PANEL_MESSAGE, 0); left_foot = xv_create(infopanel, PANEL_MESSAGE, 0);
right_foot = xv_create(infopanel, PANEL_MESSAGE, 0); right_foot = xv_create(infopanel, PANEL_MESSAGE, 0);
@ -129,20 +110,14 @@ char **argv;
*/ */
popup = xv_get(pframe, FRAME_CMD_PANEL); popup = xv_get(pframe, FRAME_CMD_PANEL);
xv_create(popup,PANEL_BUTTON, xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "HELP",
PANEL_LABEL_STRING,"HELP", PANEL_NOTIFY_PROC, HELP, 0);
PANEL_NOTIFY_PROC,HELP,
0);
xv_create(popup,PANEL_BUTTON, xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "OK",
PANEL_LABEL_STRING,"OK", PANEL_NOTIFY_PROC, DO, 0);
PANEL_NOTIFY_PROC,DO,
0);
xv_create(popup,PANEL_BUTTON, xv_create(popup, PANEL_BUTTON, PANEL_LABEL_STRING, "Cancel",
PANEL_LABEL_STRING,"Cancel", PANEL_NOTIFY_PROC, DONT, 0);
PANEL_NOTIFY_PROC,DONT,
0);
/* /*
* Keep original directory where program was started * Keep original directory where program was started
@ -151,8 +126,7 @@ char **argv;
ParseMenu(); ParseMenu();
GenMenu(type); GenMenu(type);
if(argc>1) if (argc > 1) LoadData(argv[1]);
LoadData(argv[1]);
/* /*
* Set up the basics of the displays, and off to the main loop. * Set up the basics of the displays, and off to the main loop.
@ -160,17 +134,13 @@ char **argv;
BasicDisplay(DataSet); BasicDisplay(DataSet);
if (DataSet != NULL) if (DataSet != NULL)
((NA_Alignment*)DataSet)->na_ddata = (char*)SetNADData ((NA_Alignment *)DataSet)->na_ddata = (char *)SetNADData(
((NA_Alignment*)DataSet,EditCan,EditNameCan); (NA_Alignment *)DataSet, EditCan, EditNameCan);
tool_icon = xv_create((int) NULL,ICON, tool_icon = xv_create((int)NULL, ICON, ICON_IMAGE, &iconpr, ICON_LABEL,
ICON_IMAGE,&iconpr, strlen(FileName) > 0 ? FileName : "GDE", 0);
ICON_LABEL,strlen(FileName)>0?FileName:"GDE",
0);
xv_set(frame, xv_set(frame, FRAME_ICON, tool_icon, 0);
FRAME_ICON,tool_icon,
0);
window_main_loop(frame); window_main_loop(frame);
exit(0); exit(0);