diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-01-21 16:05:43 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-01-21 16:05:43 -0800 |
commit | 692b6a728e08ff4e936728b904d7b13bc4d301ed (patch) | |
tree | 9a2373c04a39b3d7be7e14cc94e1d9ea88bca987 /tocutil.c | |
parent | 8b22282c564763bb3fb6baf5aae7b341dfbb33db (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>
Diffstat (limited to 'tocutil.c')
-rw-r--r-- | tocutil.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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; |