summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-01-21 16:05:43 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-01-21 16:05:43 -0800
commit692b6a728e08ff4e936728b904d7b13bc4d301ed (patch)
tree9a2373c04a39b3d7be7e14cc94e1d9ea88bca987
parent8b22282c564763bb3fb6baf5aae7b341dfbb33db (diff)
Convert allocation calls to XtMallocArray or XtReallocArray where appropriate
Raises minimum libXt requirement to 1.3.0 for these calls Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--bbox.c5
-rw-r--r--command.c9
-rw-r--r--configure.ac2
-rw-r--r--mlist.c5
-rw-r--r--msg.c3
-rw-r--r--pick.c12
-rw-r--r--screen.c3
-rw-r--r--toc.c8
-rw-r--r--tocutil.c16
-rw-r--r--util.c4
10 files changed, 25 insertions, 42 deletions
diff --git a/bbox.c b/bbox.c
index 443e80d..a27ae71 100644
--- a/bbox.c
+++ b/bbox.c
@@ -98,9 +98,8 @@ static void bboxAddButton(
Arg args[5];
buttonbox->numbuttons++;
- buttonbox->button = (Button *)
- XtRealloc((char *) buttonbox->button,
- (unsigned) buttonbox->numbuttons * sizeof(Button));
+ buttonbox->button = XtReallocArray(buttonbox->button,
+ buttonbox->numbuttons, sizeof(Button));
button = buttonbox->button[buttonbox->numbuttons - 1] = XtNew(ButtonRec);
button->buttonbox = buttonbox;
button->name = XtNewString(name);
diff --git a/command.c b/command.c
index 763eefd..c9a2cc5 100644
--- a/command.c
+++ b/command.c
@@ -275,8 +275,8 @@ static int _DoCommandToFileOrPipe(
case MotionNotify:
if (type_ahead_count < TYPEAHEADSIZE) {
if (++type_ahead_count == TYPEAHEADSIZE) {
- altQueue = (XEvent*)XtMalloc(
- (Cardinal)TYPEAHEADSIZE*sizeof(XEvent) );
+ altQueue = XtMallocArray(
+ (Cardinal)TYPEAHEADSIZE, sizeof(XEvent) );
alt_queue_size = TYPEAHEADSIZE;
eventP = altQueue;
}
@@ -286,9 +286,8 @@ static int _DoCommandToFileOrPipe(
else {
if (++alt_queue_count == alt_queue_size) {
alt_queue_size += TYPEAHEADSIZE;
- altQueue = (XEvent*)XtRealloc(
- (char*)altQueue,
- (Cardinal)alt_queue_size*sizeof(XEvent) );
+ altQueue = XtReallocArray(altQueue,
+ (Cardinal)alt_queue_size, sizeof(XEvent) );
eventP = &altQueue[alt_queue_count];
}
else
diff --git a/configure.ac b/configure.ac
index 024e54c..08d0b41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
# Checks for pkg-config packages
-PKG_CHECK_MODULES(XMH, xaw7 xmu xt >= 1.1 x11 xbitmaps >= 1.1.0 xproto >= 7.0.17)
+PKG_CHECK_MODULES(XMH, xaw7 xmu xt >= 1.3 x11 xbitmaps >= 1.1.0 xproto >= 7.0.17)
PKG_CHECK_MODULES(APPDEFS, xt)
xt_appdefaultdir=`$PKG_CONFIG --variable=appdefaultdir xt`
diff --git a/mlist.c b/mlist.c
index d835459..dd30891 100644
--- a/mlist.c
+++ b/mlist.c
@@ -49,9 +49,8 @@ MsgList MakeNullMsgList(void)
void AppendMsgList(MsgList mlist, Msg msg)
{
mlist->nummsgs++;
- mlist->msglist =
- (Msg *) XtRealloc((char *) mlist->msglist,
- (unsigned) (mlist->nummsgs + 1) * sizeof(Msg));
+ mlist->msglist = XtReallocArray(mlist->msglist,
+ (unsigned) (mlist->nummsgs + 1), sizeof(Msg));
mlist->msglist[mlist->nummsgs - 1] = msg;
mlist->msglist[mlist->nummsgs] = NULL;
}
diff --git a/msg.c b/msg.c
index 9f801bb..570aafc 100644
--- a/msg.c
+++ b/msg.c
@@ -302,8 +302,7 @@ static void SetScrnNewMsg(
}
} else {
msg->num_scrns++;
- msg->scrn = (Scrn *) XtRealloc((char *)msg->scrn,
- (unsigned) sizeof(Scrn)*msg->num_scrns);
+ msg->scrn = XtReallocArray(msg->scrn, msg->num_scrns, sizeof(Scrn));
msg->scrn[msg->num_scrns - 1] = scrn;
if (msg->source == NULL)
msg->source = CreateFileSource(scrn->viewwidget, MsgFileName(msg),
diff --git a/pick.c b/pick.c
index 3005e58..5d5865a 100644
--- a/pick.c
+++ b/pick.c
@@ -473,9 +473,7 @@ static FormEntry CreateWidget(
FormEntry entry;
row->numwidgets++;
- row->wlist = (FormEntry *)
- XtRealloc((char *) row->wlist,
- (unsigned) row->numwidgets * sizeof(FormEntry));
+ row->wlist = XtReallocArray(row->wlist, row->numwidgets, sizeof(FormEntry));
entry = XtNew(FormEntryRec);
entry->row = row;
entry->type = class;
@@ -533,9 +531,7 @@ static RowList AddRow(Group group, int type)
};
RowList row;
group->numrows++;
- group->rlist = (RowList *)
- XtRealloc((char *) group->rlist,
- (unsigned) group->numrows * sizeof(RowList));
+ group->rlist = XtReallocArray(group->rlist, group->numrows, sizeof(RowList));
group->rlist[group->numrows - 1] = row = XtNew(RowListRec);
row->type = type;
row->numwidgets = 0;
@@ -575,9 +571,7 @@ static Group AddGroup(FormBox form)
};
Group group;
form->numgroups++;
- form->glist = (Group *)
- XtRealloc((char *) form->glist,
- (unsigned) form->numgroups * sizeof(Group));
+ form->glist = XtReallocArray(form->glist, form->numgroups, sizeof(Group));
form->glist[form->numgroups - 1] = group =
(Group) XtMalloc((Cardinal) sizeof(GroupRec));
group->numrows = 0;
diff --git a/screen.c b/screen.c
index 67fd7e3..687fec4 100644
--- a/screen.c
+++ b/screen.c
@@ -294,8 +294,7 @@ Scrn CreateNewScrn(ScrnKind kind)
}
numScrns++;
- scrnList = (Scrn *)
- XtRealloc((char *) scrnList, (unsigned) numScrns*sizeof(Scrn));
+ scrnList = XtReallocArray(scrnList, numScrns, sizeof(Scrn));
scrn = scrnList[numScrns - 1] = XtNew(ScrnRec);
bzero((char *)scrn, sizeof(ScrnRec));
scrn->kind = kind;
diff --git a/toc.c b/toc.c
index a018a7a..2a1d507 100644
--- a/toc.c
+++ b/toc.c
@@ -186,7 +186,7 @@ void TocInit(void)
else
MakeSureFolderExists(&namelist, &numFolders,
app_resources.drafts_folder_name);
- folderList = (Toc *) XtMalloc((Cardinal)numFolders * sizeof(Toc));
+ folderList = XtMallocArray((Cardinal)numFolders, sizeof(Toc));
for (i=0 ; i<numFolders ; i++) {
toc = folderList[i] = TUMalloc();
toc->foldername = XtNewString(namelist[i]);
@@ -210,8 +210,7 @@ Toc TocCreate(const char *foldername)
Toc toc = TUMalloc();
toc->foldername = XtNewString(foldername);
- folderList = (Toc *) XtRealloc((char *) folderList,
- (unsigned) ++numFolders * sizeof(Toc));
+ folderList = XtReallocArray(folderList, ++numFolders, sizeof(Toc));
folderList[numFolders - 1] = toc;
return toc;
}
@@ -432,8 +431,7 @@ void TocSetScrn(Toc toc, Scrn scrn)
StoreWindowName(scrn, progName);
} else {
toc->num_scrns++;
- toc->scrn = (Scrn *) XtRealloc((char *) toc->scrn,
- (unsigned)toc->num_scrns*sizeof(Scrn));
+ toc->scrn = XtReallocArray(toc->scrn, toc->num_scrns, sizeof(Scrn));
toc->scrn[toc->num_scrns - 1] = scrn;
TUEnsureScanIsValidAndOpen(toc, True);
TUResetTocLabel(scrn);
diff --git a/tocutil.c b/tocutil.c
index 07a8387..04d5d91 100644
--- a/tocutil.c
+++ b/tocutil.c
@@ -277,9 +277,8 @@ void TULoadSeqLists(Toc toc)
strcmp(ptr, "cur") != 0 &&
strcmp(ptr, "unseen") != 0) {
toc->numsequences++;
- toc->seqlist = (Sequence *)
- XtRealloc((char *) toc->seqlist, (Cardinal)
- toc->numsequences * sizeof(Sequence));
+ toc->seqlist = XtReallocArray(toc->seqlist,
+ toc->numsequences, sizeof(Sequence));
seq = toc->seqlist[toc->numsequences - 1] =
XtNew(SequenceRec);
seq->name = XtNewString(ptr);
@@ -378,7 +377,7 @@ void TULoadTocFile(Toc toc)
if (maxmsgs == 0) maxmsgs = 100;
toc->nummsgs = 0;
origmsgs = toc->msgs;
- toc->msgs = (Msg *) XtMalloc((Cardinal) maxmsgs * sizeof(Msg));
+ toc->msgs = XtMallocArray((Cardinal) maxmsgs, sizeof(Msg));
position = 0;
i = 0;
curmsg = NULL;
@@ -410,8 +409,7 @@ void TULoadTocFile(Toc toc)
msg->visible = TRUE;
if (toc->nummsgs >= maxmsgs) {
maxmsgs += 100;
- toc->msgs = (Msg *) XtRealloc((char *) toc->msgs,
- (Cardinal) maxmsgs * sizeof(Msg));
+ toc->msgs = XtReallocArray(toc->msgs, maxmsgs, sizeof(Msg));
}
while (i < orignummsgs && origmsgs[i]->msgid < msg->msgid) i++;
if (i < orignummsgs) {
@@ -421,8 +419,7 @@ void TULoadTocFile(Toc toc)
}
}
toc->length = toc->origlength = toc->lastPos = position;
- toc->msgs = (Msg *) XtRealloc((char *) toc->msgs,
- (Cardinal) toc->nummsgs * sizeof(Msg));
+ toc->msgs = XtReallocArray(toc->msgs, toc->nummsgs, sizeof(Msg));
(void) myfclose(fid);
if ( (toc->source == NULL) && ( toc->num_scrns > 0 ) ) {
Arg args[1];
@@ -608,8 +605,7 @@ Msg TUAppendToc(Toc toc, const char *ptr)
else
msgid = 1;
(toc->nummsgs)++;
- toc->msgs = (Msg *) XtRealloc((char *) toc->msgs,
- (Cardinal) toc->nummsgs * sizeof(Msg));
+ toc->msgs = XtReallocArray(toc->msgs, toc->nummsgs, sizeof(Msg));
toc->msgs[toc->nummsgs - 1] = msg = XtNew(MsgRec);
bzero((char *) msg, (int) sizeof(MsgRec));
msg->toc = toc;
diff --git a/util.c b/util.c
index 2ee8106..d806897 100644
--- a/util.c
+++ b/util.c
@@ -119,7 +119,7 @@ char *MakeNewTempFileName(void)
char **MakeArgv(int n)
{
char **result;
- result = ((char **) XtMalloc((unsigned) (n+1) * sizeof(char *)));
+ result = XtMallocArray((unsigned) (n+1), sizeof(char *));
result[n] = NULL;
return result;
}
@@ -127,7 +127,7 @@ char **MakeArgv(int n)
char **ResizeArgv(char **argv, int n)
{
- argv = ((char **) XtRealloc((char *) argv, (unsigned) (n+1) * sizeof(char *)));
+ argv = XtReallocArray(argv, (unsigned) (n+1), sizeof(char *));
argv[n] = NULL;
return argv;
}