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/icon.h>
#include <xview/panel.h>
#include <xview/window.h>
#include <xview/xview.h> #include <xview/xview.h>
#include <xview/panel.h>
#include <xview/window.h>
#include <xview/icon.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,152 +26,121 @@ All rights reserved.
*/ */
Gmenu menu[100]; Gmenu menu[100];
int num_menus = 0,repeat_cnt = 0; // int num_menus = 0;
Frame frame,pframe,infoframe; int repeat_cnt = 0;
Panel popup,infopanel; Frame frame, pframe, infoframe;
Panel_item left_foot,right_foot; Panel popup, infopanel;
Canvas EditCan,EditNameCan; Panel_item left_foot, right_foot;
Canvas EditCan, EditNameCan;
int DisplayType; int DisplayType;
GmenuItem *current_item; GmenuItem *current_item;
NA_Alignment *DataSet = NULL; NA_Alignment *DataSet = NULL;
NA_Alignment *Clipboard = NULL; NA_Alignment *Clipboard = NULL;
char **TextClip; char **TextClip;
int TextClipSize = 0,TextClipLength = 0; 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 */
extern char FileName[], current_dir[];
Icon tool_icon; /* obvious */ int type = GENBANK; /* default file type */
extern char FileName[],current_dir[];
int type = GENBANK; /* default file type */
DataSet = NULL; DataSet = NULL;
Clipboard = (NA_Alignment*)Calloc(1,sizeof(NA_Alignment)); Clipboard = (NA_Alignment *)Calloc(1, sizeof(NA_Alignment));
DisplayType = NASEQ_ALIGN; /* default data type */ DisplayType = NASEQ_ALIGN; /* default data type */
Clipboard->maxnumelements = 5; Clipboard->maxnumelements = 5;
Clipboard->element =(NA_Sequence*)Calloc(Clipboard->maxnumelements, Clipboard->element = (NA_Sequence *)Calloc(Clipboard->maxnumelements,
sizeof(NA_Sequence)); sizeof(NA_Sequence));
/*
* Connect to server, and set up initial XView data types
* that are common to ALL display types
*/
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc,argv,0);
/* /*
* Main frame (primary window); * Connect to server, and set up initial XView data types
*/ * that are common to ALL display types
*/
frame = xv_create((int) NULL,FRAME, xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
FRAME_NO_CONFIRM,FALSE,
FRAME_LABEL, "Genetic Data Environment 2.2",
FRAME_INHERIT_COLORS,TRUE,
XV_WIDTH,700,
XV_HEIGHT,500,
FRAME_SHOW_FOOTER,TRUE,
0);
/* /*
* Popup frame (dialog box window), and default settings in * Main frame (primary window);
* the dialog box. These are changed to fit each individual */
* command's needs in EventHandler().
*/
infoframe = xv_create(frame,FRAME_CMD,
FRAME_LABEL,"Messages",
WIN_DESIRED_HEIGHT,100,
WIN_DESIRED_WIDTH,300,
FRAME_SHOW_RESIZE_CORNER,TRUE,
FRAME_INHERIT_COLORS,TRUE,
FRAME_CLOSED,FALSE,
WIN_SHOW,FALSE,
0);
pframe = xv_create(frame,FRAME_CMD, frame = xv_create((int)NULL, FRAME, FRAME_NO_CONFIRM, FALSE,
FRAME_CMD_PUSHPIN_IN,TRUE, FRAME_LABEL, "Genetic Data Environment 2.2",
FRAME_DONE_PROC,FrameDone, FRAME_INHERIT_COLORS, TRUE, XV_WIDTH, 700, XV_HEIGHT,
XV_HEIGHT,100, 500, FRAME_SHOW_FOOTER, TRUE, 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); /*
xv_set(infopanel, PANEL_LAYOUT,PANEL_VERTICAL, * Popup frame (dialog box window), and default settings in
XV_WIDTH,300, * the dialog box. These are changed to fit each individual
XV_HEIGHT,50, * command's needs in EventHandler().
0); */
infoframe =
xv_create(frame, FRAME_CMD, FRAME_LABEL, "Messages",
WIN_DESIRED_HEIGHT, 100, WIN_DESIRED_WIDTH, 300,
FRAME_SHOW_RESIZE_CORNER, TRUE, FRAME_INHERIT_COLORS,
TRUE, FRAME_CLOSED, FALSE, WIN_SHOW, FALSE, 0);
left_foot = xv_create(infopanel,PANEL_MESSAGE,0); pframe = xv_create(frame, FRAME_CMD, FRAME_CMD_PUSHPIN_IN, TRUE,
right_foot = xv_create(infopanel,PANEL_MESSAGE,0); FRAME_DONE_PROC, FrameDone, XV_HEIGHT, 100, 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);
xv_set(infopanel, PANEL_LAYOUT, PANEL_VERTICAL, XV_WIDTH, 300,
XV_HEIGHT, 50, 0);
left_foot = xv_create(infopanel, PANEL_MESSAGE, 0);
right_foot = xv_create(infopanel, PANEL_MESSAGE, 0);
window_fit(infoframe); window_fit(infoframe);
/* /*
popup = xv_create(pframe,PANEL, popup = xv_create(pframe,PANEL,
PANEL_LAYOUT,PANEL_HORIZONTAL, PANEL_LAYOUT,PANEL_HORIZONTAL,
0); 0);
*/ */
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
*/ */
(void)getwd(current_dir); (void)getwd(current_dir);
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.
*/ */
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);