diff options
-rw-r--r-- | src/Converters.c | 4 | ||||
-rw-r--r-- | src/Display.c | 10 | ||||
-rw-r--r-- | src/Event.c | 6 | ||||
-rw-r--r-- | src/EventUtil.c | 2 | ||||
-rw-r--r-- | src/GCManager.c | 6 | ||||
-rw-r--r-- | src/GetResList.c | 6 | ||||
-rw-r--r-- | src/Initialize.c | 8 | ||||
-rw-r--r-- | src/Intrinsic.c | 2 | ||||
-rw-r--r-- | src/Manage.c | 3 | ||||
-rw-r--r-- | src/Object.c | 5 | ||||
-rw-r--r-- | src/PassivGrab.c | 4 | ||||
-rw-r--r-- | src/ResConfig.c | 3 | ||||
-rw-r--r-- | src/Resources.c | 14 | ||||
-rw-r--r-- | src/Selection.c | 23 | ||||
-rw-r--r-- | src/SetWMCW.c | 4 | ||||
-rw-r--r-- | src/Shell.c | 8 | ||||
-rw-r--r-- | src/TMaction.c | 9 | ||||
-rw-r--r-- | src/TMkey.c | 9 | ||||
-rw-r--r-- | src/TMparse.c | 3 | ||||
-rw-r--r-- | src/TMstate.c | 71 | ||||
-rw-r--r-- | src/Threads.c | 3 | ||||
-rw-r--r-- | src/VarGet.c | 2 |
22 files changed, 91 insertions, 114 deletions
diff --git a/src/Converters.c b/src/Converters.c index 97f1ce5..f34aef2 100644 --- a/src/Converters.c +++ b/src/Converters.c @@ -1719,8 +1719,8 @@ XtCvtStringToCommandArgArray(Display *dpy, dst++; } - ptr = strarray = (String *) - __XtMalloc((Cardinal) ((size_t) (tokens + 1) * sizeof(String))); + ptr = strarray = XtMallocArray((Cardinal) tokens + 1, + (Cardinal) sizeof(String)); src = dst_str; while (--tokens >= 0) { *ptr = src; diff --git a/src/Display.c b/src/Display.c index 879b71a..c4928a0 100644 --- a/src/Display.c +++ b/src/Display.c @@ -346,9 +346,8 @@ _XtAppInit(XtAppContext *app_context_return, /* * Save away argv and argc so we can set the properties later */ - saved_argv = (_XtString *) - __XtMalloc((Cardinal) - ((size_t) (*argc_in_out + 1) * sizeof(_XtString))); + saved_argv = XtMallocArray((Cardinal) *argc_in_out + 1, + (Cardinal) sizeof(_XtString)); for (i = 0; i < *argc_in_out; i++) saved_argv[i] = (*argv_in_out)[i]; @@ -817,9 +816,8 @@ XtGetDisplays(XtAppContext app_context, LOCK_APP(app_context); *num_dpy_return = (Cardinal) app_context->count; - *dpy_return = (Display **) - __XtMalloc((Cardinal) - ((size_t) app_context->count * sizeof(Display *))); + *dpy_return = XtMallocArray((Cardinal) app_context->count, + (Cardinal) sizeof(Display *)); for (ii = 0; ii < app_context->count; ii++) (*dpy_return)[ii] = app_context->list[ii]; UNLOCK_APP(app_context); diff --git a/src/Event.c b/src/Event.c index 3939a18..b485931 100644 --- a/src/Event.c +++ b/src/Event.c @@ -768,10 +768,8 @@ CallEventHandlers(Widget widget, XEvent *event, EventMask mask) (p->has_type_specifier && event->type == EXT_TYPE(p))) numprocs++; } - proc = (XtEventHandler *) - __XtMalloc((Cardinal) - ((size_t) numprocs * - (sizeof(XtEventHandler) + sizeof(XtPointer)))); + proc = XtMallocArray((Cardinal) numprocs, (Cardinal) + (sizeof(XtEventHandler) + sizeof(XtPointer))); closure = (XtPointer *) (proc + numprocs); numprocs = 0; diff --git a/src/EventUtil.c b/src/EventUtil.c index 37e441a..1d41255 100644 --- a/src/EventUtil.c +++ b/src/EventUtil.c @@ -146,7 +146,7 @@ _XtFillAncestorList(Widget **listPtr, /* First time in, allocate the ancestor list */ if (trace == NULL) { - trace = (Widget *) __XtMalloc(CACHESIZE * sizeof(Widget)); + trace = XtMallocArray(CACHESIZE, (Cardinal) sizeof(Widget)); *maxElemsPtr = CACHESIZE; } /* First fill in the ancestor list */ diff --git a/src/GCManager.c b/src/GCManager.c index aa5bbba..1c1a2cd 100644 --- a/src/GCManager.c +++ b/src/GCManager.c @@ -250,10 +250,8 @@ XtAllocateGC(register Widget widget, if (!pd->pixmap_tab) { int n; - pd->pixmap_tab = - (Drawable **) - __XtMalloc((Cardinal) - ((unsigned) ScreenCount(dpy) * sizeof(Drawable *))); + pd->pixmap_tab = XtMallocArray((Cardinal) ScreenCount(dpy), + (Cardinal) sizeof(Drawable *)); for (n = 0; n < ScreenCount(dpy); n++) pd->pixmap_tab[n] = NULL; } diff --git a/src/GetResList.c b/src/GetResList.c index 3bb2387..cc3ee4e 100644 --- a/src/GetResList.c +++ b/src/GetResList.c @@ -90,8 +90,9 @@ XtGetResourceList(WidgetClass widget_class, register XtResourceList *list, dlist; LOCK_PROCESS; + *resources = XtMallocArray(widget_class->core_class.num_resources, + (Cardinal) sizeof(XtResource)); size = (int) (widget_class->core_class.num_resources * sizeof(XtResource)); - *resources = (XtResourceList) __XtMalloc((unsigned) size); if (!widget_class->core_class.class_inited) { /* Easy case */ @@ -162,8 +163,9 @@ XtGetConstraintResourceList(WidgetClass widget_class, return; } + *resources = XtMallocArray(class->constraint_class.num_resources, + (Cardinal) sizeof(XtResource)); size = (int) (class->constraint_class.num_resources * sizeof(XtResource)); - *resources = (XtResourceList) __XtMalloc((unsigned) size); if (!class->core_class.class_inited) { /* Easy case */ diff --git a/src/Initialize.c b/src/Initialize.c index ff5eee8..03bb59c 100644 --- a/src/Initialize.c +++ b/src/Initialize.c @@ -668,9 +668,8 @@ _MergeOptionTables(const XrmOptionDescRec *src1, int dst_len, order; enum { Check, NotSorted, IsSorted } sort_order = Check; - *dst = table = (XrmOptionDescRec *) - __XtMalloc((Cardinal) - (sizeof(XrmOptionDescRec) * (num_src1 + num_src2))); + *dst = table = XtMallocArray(num_src1 + num_src2, + (Cardinal) sizeof(XrmOptionDescRec)); (void) memcpy(table, src1, sizeof(XrmOptionDescRec) * num_src1); if (num_src2 == 0) { @@ -786,8 +785,7 @@ _XtPreparseCommandLine(XrmOptionDescRec *urlist, _XtString *targv; int targc = argc; - targv = (_XtString *) - __XtMalloc((Cardinal) (sizeof(_XtString *) * (size_t) argc)); + targv = XtMallocArray((Cardinal) argc, (Cardinal) sizeof(_XtString *)); (void) memcpy(targv, argv, sizeof(char *) * (size_t) argc); _MergeOptionTables(opTable, XtNumber(opTable), urlist, num_urs, &options, &num_options); diff --git a/src/Intrinsic.c b/src/Intrinsic.c index 7ca4e7c..88d66e7 100644 --- a/src/Intrinsic.c +++ b/src/Intrinsic.c @@ -1309,7 +1309,7 @@ FillInLangSubs(Substitution subs, XtPerDisplay pd) len = (int) strlen(string) + 1; subs[0].substitution = (_XtString) string; - p1 = subs[1].substitution = __XtMalloc((Cardinal) (3 * len)); + p1 = subs[1].substitution = XtMallocArray(3, (Cardinal) len); p2 = subs[2].substitution = subs[1].substitution + len; p3 = subs[3].substitution = subs[2].substitution + len; diff --git a/src/Manage.c b/src/Manage.c index 39097ee..7881094 100644 --- a/src/Manage.c +++ b/src/Manage.c @@ -243,8 +243,7 @@ ManageChildren(WidgetList children, unique_children = cache; } else { - unique_children = (WidgetList) - __XtMalloc((Cardinal) ((size_t) num_children * sizeof(Widget))); + unique_children = XtMallocArray(num_children, (Cardinal) sizeof(Widget)); } num_unique_children = 0; for (i = 0; i < num_children; i++) { diff --git a/src/Object.c b/src/Object.c index c5a3a58..ef9f0c1 100644 --- a/src/Object.c +++ b/src/Object.c @@ -179,9 +179,8 @@ ConstructCallbackOffsets(WidgetClass myWidgetClass) * offsets occur in the table ahead of the superclass callback * offsets so that resource overrides work. */ - newTable = (CallbackTable) - __XtMalloc((Cardinal) - (sizeof(XrmResource *) * (size_t) (tableSize + 1))); + newTable = XtMallocArray((Cardinal) tableSize + 1, + (Cardinal) sizeof(XrmResource *)); newTable[0] = (XrmResource *) (XtIntPtr) tableSize; diff --git a/src/PassivGrab.c b/src/PassivGrab.c index 82f8dae..b5f82a3 100644 --- a/src/PassivGrab.c +++ b/src/PassivGrab.c @@ -108,7 +108,7 @@ DeleteDetailFromMask(Mask **ppDetailMask, unsigned short detail) if (!pDetailMask) { int i; - pDetailMask = (Mask *) __XtMalloc(sizeof(Mask) * MasksPerDetailMask); + pDetailMask = XtMallocArray(MasksPerDetailMask, (Cardinal) sizeof(Mask)); for (i = MasksPerDetailMask; --i >= 0;) pDetailMask[i] = (unsigned long) (~0); *ppDetailMask = pDetailMask; @@ -129,7 +129,7 @@ CopyDetailMask(const Mask *pOriginalDetailMask) if (!pOriginalDetailMask) return NULL; - pTempMask = (Mask *) __XtMalloc(sizeof(Mask) * MasksPerDetailMask); + pTempMask = XtMallocArray(MasksPerDetailMask, (Cardinal) sizeof(Mask)); for (i = 0; i < MasksPerDetailMask; i++) pTempMask[i] = pOriginalDetailMask[i]; diff --git a/src/ResConfig.c b/src/ResConfig.c index c12fed5..2ba68b0 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -781,8 +781,7 @@ _locate_children(Widget parent, Widget **children) return (0); } - *children = (Widget *) - XtMalloc((Cardinal) (sizeof(Widget) * (size_t) num_children)); + *children = XtMallocArray((Cardinal)num_children, (Cardinal)sizeof(Widget)); if (XtIsComposite(parent)) { for (i = 0; i < comp->composite.num_children; i++) { diff --git a/src/Resources.c b/src/Resources.c index 274f9d7..cb60ab2 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -374,8 +374,7 @@ _XtDependencies(XtResourceList *class_resp, /* VAR */ /* Allocate and initialize new_res with superclass resource pointers */ new_num_res = super_num_res + class_num_res; - new_res = (XrmResourceList *) - __XtMalloc((Cardinal) (new_num_res * sizeof(XrmResourceList))); + new_res = XtMallocArray(new_num_res, (Cardinal) sizeof(XrmResourceList)); if (super_num_res > 0) memcpy(new_res, super_res, super_num_res * sizeof(XrmResourceList)); @@ -461,8 +460,7 @@ _XtCreateIndirectionTable(XtResourceList resources, Cardinal num_resources) register Cardinal idx; XrmResourceList *table; - table = (XrmResourceList *) - __XtMalloc((Cardinal) (num_resources * sizeof(XrmResourceList))); + table = XtMallocArray(num_resources, (Cardinal) sizeof(XrmResourceList)); for (idx = 0; idx < num_resources; idx++) table[idx] = (XrmResourceList) (&(resources[idx])); return table; @@ -920,9 +918,8 @@ GetResources(Widget widget, /* Widget resources are associated with cache_ptr = cache_base; if (cache_ptr && cache_ptr != cache_ref) { int cache_ref_size = (int) (cache_ptr - cache_ref); - XtCacheRef *refs = (XtCacheRef *) - __XtMalloc((Cardinal) - (sizeof(XtCacheRef) * (size_t) (cache_ref_size + 1))); + XtCacheRef *refs = XtMallocArray((Cardinal) cache_ref_size + 1, + (Cardinal) sizeof(XtCacheRef)); (void) memcpy(refs, cache_ref, sizeof(XtCacheRef) * (size_t) cache_ref_size); @@ -948,8 +945,7 @@ CacheArgs(ArgList args, count = (args != NULL) ? num_args : num_typed_args; if (num_quarks < count) { - quarks = - (XrmQuarkList) __XtMalloc((Cardinal) (count * sizeof(XrmQuark))); + quarks = XtMallocArray(count, (Cardinal) sizeof(XrmQuark)); } else { quarks = quark_cache; diff --git a/src/Selection.c b/src/Selection.c index 618d73b..1821cb4 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -286,13 +286,12 @@ MakeInfo(Select ctx, CallBackInfo info = XtNew(CallBackInfoRec); info->ctx = ctx; - info->callbacks = (XtSelectionCallbackProc *) - __XtMalloc((unsigned) - ((size_t) count * sizeof(XtSelectionCallbackProc))); + info->callbacks = XtMallocArray((Cardinal) count, + (Cardinal) sizeof(XtSelectionCallbackProc)); (void) memcpy(info->callbacks, callbacks, (size_t) count * sizeof(XtSelectionCallbackProc)); - info->req_closure = (XtPointer *) - __XtMalloc((unsigned) ((size_t) count * sizeof(XtPointer))); + info->req_closure = XtMallocArray((Cardinal) count, + (Cardinal) sizeof(XtPointer)); (void) memcpy(info->req_closure, closures, (size_t) count * sizeof(XtPointer)); if (count == 1 && properties != NULL && properties[0] != None) @@ -304,8 +303,8 @@ MakeInfo(Select ctx, info->proc = HandleSelectionReplies; info->widget = widget; info->time = time; - info->incremental = - (Boolean *) __XtMalloc((Cardinal) ((size_t) count * sizeof(Boolean))); + info->incremental = XtMallocArray((Cardinal) count, + (Cardinal) sizeof(Boolean)); (void) memcpy(info->incremental, incremental, (size_t) count * sizeof(Boolean)); info->current = 0; @@ -1751,13 +1750,13 @@ GetSelectionValues(Widget widget, time, incremental, properties); XtStackFree((XtPointer) passed_callbacks, stack_cbs); - info->target = (Atom *) - __XtMalloc((unsigned) ((size_t) (count + 1) * sizeof(Atom))); + info->target = XtMallocArray ((Cardinal) count + 1, + (Cardinal) sizeof(Atom)); (*info->target) = ctx->prop_list->indirect_atom; (void) memcpy((char *) info->target + sizeof(Atom), targets, (size_t) count * sizeof(Atom)); - pairs = (IndirectPair *) - __XtMalloc((unsigned) ((size_t) count * sizeof(IndirectPair))); + pairs = XtMallocArray ((Cardinal) count + 1, + (Cardinal) sizeof(IndirectPair)); for (p = &pairs[count - 1], t = &targets[count - 1], i = count - 1; p >= pairs; p--, t--, i--) { p->target = *t; @@ -2088,7 +2087,7 @@ XtCreateSelectionRequest(Widget widget, Atom selection) queueInfo = (QueuedRequestInfo) __XtMalloc(sizeof(QueuedRequestInfoRec)); queueInfo->count = 0; - queueInfo->selections = (Atom *) __XtMalloc(sizeof(Atom) * 2); + queueInfo->selections = XtMallocArray(2, (Cardinal) sizeof(Atom)); queueInfo->selections[0] = None; queueInfo->requests = (QueuedRequest *) __XtMalloc(sizeof(QueuedRequest)); diff --git a/src/SetWMCW.c b/src/SetWMCW.c index 413142b..52b71e5 100644 --- a/src/SetWMCW.c +++ b/src/SetWMCW.c @@ -92,7 +92,7 @@ XtSetWMColormapWindows(Widget widget, Widget *list, Cardinal count) return; } - top = checked = (Widget *) __XtMalloc((Cardinal) sizeof(Widget) * count); + top = checked = XtMallocArray(count, (Cardinal) sizeof(Widget)); /* * The specification calls for only adding the windows that have unique @@ -136,7 +136,7 @@ XtSetWMColormapWindows(Widget widget, Widget *list, Cardinal count) * windows and set the property. */ - data = (Window *) __XtMalloc((Cardinal) sizeof(Window) * checked_count); + data = XtMallocArray(checked_count, (Cardinal) sizeof(Window)); for (i = 0; i < checked_count; i++) data[i] = XtWindow(top[i]); diff --git a/src/Shell.c b/src/Shell.c index 5cf4bc2..82616ef 100644 --- a/src/Shell.c +++ b/src/Shell.c @@ -3492,8 +3492,8 @@ EditCommand(_XtString str, /* if not NULL, the sm_client_id */ count++; if (want) { - s = new = (_XtString *) - __XtMalloc((Cardinal) ((size_t) (count + 3) * sizeof(_XtString *))); + s = new = XtMallocArray((Cardinal) count + 3, + (Cardinal) sizeof(_XtString *)); *s = *sarray; s++; sarray++; @@ -3508,8 +3508,8 @@ EditCommand(_XtString str, /* if not NULL, the sm_client_id */ else { if (count < 3) return NewStringArray(sarray); - s = new = (_XtString *) - __XtMalloc((Cardinal) ((size_t) (count - 1) * sizeof(_XtString *))); + s = new = XtMallocArray((Cardinal) count - 1, + (Cardinal) sizeof(_XtString *)); for (; --count >= 0; sarray++) { if (strcmp(*sarray, "-xtsessionID") == 0) { sarray++; diff --git a/src/TMaction.c b/src/TMaction.c index 3fbc879..c577b71 100644 --- a/src/TMaction.c +++ b/src/TMaction.c @@ -110,8 +110,8 @@ CompileActionTable(register RConst struct _XtActionsRec *actions, register Cardi func = (perm ? XrmPermStringToQuark : XrmStringToQuark); if (!stat) { - cTableHold = cActions = (CompiledActionTable) - __XtMalloc((Cardinal) ((size_t) count * sizeof(CompiledAction))); + cTableHold = cActions = XtMallocArray(count, + (Cardinal) sizeof(CompiledAction)); for (i = (int) count; --i >= 0; cActions++, actions++) { cActions->proc = actions->proc; @@ -761,9 +761,8 @@ XtGetActionList(WidgetClass widget_class, } *num_actions_return = widget_class->core_class.num_actions; if (*num_actions_return) { - XtActionList list = *actions_return = (XtActionList) - __XtMalloc((Cardinal) - ((size_t) *num_actions_return * sizeof(XtActionsRec))); + XtActionList list = *actions_return = + XtMallocArray(*num_actions_return, (Cardinal) sizeof(XtActionsRec)); table = GetClassActions(widget_class); diff --git a/src/TMkey.c b/src/TMkey.c index 40a5c19..aa3f8d9 100644 --- a/src/TMkey.c +++ b/src/TMkey.c @@ -456,15 +456,12 @@ _XtBuildKeysymTables(Display *dpy, register XtPerDisplay pd) &pd->keysyms_per_keycode); XtFree((char *) pd->modKeysyms); - pd->modKeysyms = - (KeySym *) __XtMalloc((Cardinal) KeysymTableSize * sizeof(KeySym)); + pd->modKeysyms = XtMallocArray(KeysymTableSize, (Cardinal) sizeof(KeySym)); maxCount = KeysymTableSize; tempCount = 0; XtFree((char *) pd->modsToKeysyms); - table = - (ModToKeysymTable *) __XtMalloc((Cardinal) 8 * - sizeof(ModToKeysymTable)); + table = XtMallocArray(8, (Cardinal) sizeof(ModToKeysymTable)); pd->modsToKeysyms = table; table[0].mask = ShiftMask; @@ -739,7 +736,7 @@ XtKeysymToKeycodeList(Display *dpy, KeyCode *old = keycodes; maxcodes += KEYCODE_ARRAY_SIZE; - keycodes = (KeyCode *) __XtMalloc(maxcodes * sizeof(KeyCode)); + keycodes = XtMallocArray(maxcodes, (Cardinal) sizeof(KeyCode)); if (ncodes) { (void) memcpy(keycodes, old, ncodes * sizeof(KeyCode)); XtFree((char *) old); diff --git a/src/TMparse.c b/src/TMparse.c index 2fe7fe5..f93244c 100644 --- a/src/TMparse.c +++ b/src/TMparse.c @@ -1803,8 +1803,7 @@ ParseParamSeq(register String str, String **paramSeqP, Cardinal *paramNumP) } if (num_params != 0) { - String *paramP = (String *) - __XtMalloc((Cardinal) ((num_params + 1) * sizeof(String))); + String *paramP = XtMallocArray(num_params + 1, (Cardinal)sizeof(String)); Cardinal i; *paramSeqP = paramP; diff --git a/src/TMstate.c b/src/TMstate.c index 7a5a04d..8dbf054 100644 --- a/src/TMstate.c +++ b/src/TMstate.c @@ -123,20 +123,20 @@ GetBranchHead(TMParseStateTree parseTree, } } if (parseTree->numBranchHeads == parseTree->branchHeadTblSize) { - TMShortCard newSize; if (parseTree->branchHeadTblSize == 0) parseTree->branchHeadTblSize = TM_BRANCH_HEAD_TBL_ALLOC; else parseTree->branchHeadTblSize += TM_BRANCH_HEAD_TBL_REALLOC; - newSize = - (TMShortCard) (parseTree->branchHeadTblSize * - sizeof(TMBranchHeadRec)); + if (parseTree->isStackBranchHeads) { TMBranchHead oldBranchHeadTbl = parseTree->branchHeadTbl; - parseTree->branchHeadTbl = (TMBranchHead) __XtMalloc(newSize); - memcpy(parseTree->branchHeadTbl, oldBranchHeadTbl, newSize); + parseTree->branchHeadTbl = + XtMallocArray((Cardinal) parseTree->branchHeadTblSize, + (Cardinal) sizeof(TMBranchHeadRec)); + memcpy(parseTree->branchHeadTbl, oldBranchHeadTbl, + parseTree->branchHeadTblSize * sizeof(TMBranchHeadRec)); parseTree->isStackBranchHeads = False; } else { @@ -174,20 +174,20 @@ _XtGetQuarkIndex(TMParseStateTree parseTree, XrmQuark quark) if (i == parseTree->numQuarks) { if (parseTree->numQuarks == parseTree->quarkTblSize) { - TMShortCard newSize; if (parseTree->quarkTblSize == 0) parseTree->quarkTblSize = TM_QUARK_TBL_ALLOC; else parseTree->quarkTblSize += TM_QUARK_TBL_REALLOC; - newSize = - (TMShortCard) (parseTree->quarkTblSize * sizeof(XrmQuark)); if (parseTree->isStackQuarks) { XrmQuark *oldquarkTbl = parseTree->quarkTbl; - parseTree->quarkTbl = (XrmQuark *) __XtMalloc(newSize); - memcpy(parseTree->quarkTbl, oldquarkTbl, newSize); + parseTree->quarkTbl = + XtMallocArray((Cardinal) parseTree->quarkTblSize, + (Cardinal) sizeof(XrmQuark)); + memcpy(parseTree->quarkTbl, oldquarkTbl, + parseTree->quarkTblSize * sizeof(XrmQuark)); parseTree->isStackQuarks = False; } else { @@ -215,8 +215,6 @@ GetComplexBranchIndex(TMParseStateTree parseTree, #define TM_COMPLEXBRANCH_HEAD_TBL_REALLOC 4 if (parseTree->numComplexBranchHeads == parseTree->complexBranchHeadTblSize) { - TMShortCard newSize; - if (parseTree->complexBranchHeadTblSize == 0) parseTree->complexBranchHeadTblSize = (TMShortCard) (parseTree->complexBranchHeadTblSize + @@ -226,16 +224,14 @@ GetComplexBranchIndex(TMParseStateTree parseTree, (TMShortCard) (parseTree->complexBranchHeadTblSize + TM_COMPLEXBRANCH_HEAD_TBL_REALLOC); - newSize = - (TMShortCard) (parseTree->complexBranchHeadTblSize * - sizeof(StatePtr)); - if (parseTree->isStackComplexBranchHeads) { StatePtr *oldcomplexBranchHeadTbl = parseTree->complexBranchHeadTbl; - parseTree->complexBranchHeadTbl = (StatePtr *) __XtMalloc(newSize); - memcpy(parseTree->complexBranchHeadTbl, - oldcomplexBranchHeadTbl, newSize); + parseTree->complexBranchHeadTbl = + XtMallocArray((Cardinal) parseTree->complexBranchHeadTblSize, + (Cardinal) sizeof(StatePtr)); + memcpy(parseTree->complexBranchHeadTbl, oldcomplexBranchHeadTbl, + parseTree->complexBranchHeadTblSize * sizeof(StatePtr)); parseTree->isStackComplexBranchHeads = False; } else { @@ -285,8 +281,8 @@ _XtGetTypeIndex(Event *event) (Cardinal) sizeof(TMTypeMatch)); } _XtGlobalTM.typeMatchSegmentTbl[_XtGlobalTM.numTypeMatchSegments++] = - segment = (TMTypeMatch) - __XtMalloc(TM_TYPE_SEGMENT_SIZE * sizeof(TMTypeMatchRec)); + segment = XtMallocArray(TM_TYPE_SEGMENT_SIZE, + (Cardinal) sizeof(TMTypeMatchRec)); j = 0; } typeMatch = &segment[j]; @@ -387,8 +383,8 @@ _XtGetModifierIndex(Event *event) (Cardinal) sizeof(TMModifierMatch)); } _XtGlobalTM.modMatchSegmentTbl[_XtGlobalTM.numModMatchSegments++] = - segment = (TMModifierMatch) - __XtMalloc(TM_MOD_SEGMENT_SIZE * sizeof(TMModifierMatchRec)); + segment = XtMallocArray(TM_MOD_SEGMENT_SIZE, + (Cardinal) sizeof(TMModifierMatchRec)); j = 0; } modMatch = &segment[j]; @@ -1402,19 +1398,18 @@ TMStateTree _XtParseTreeToStateTree(TMParseStateTree parseTree) { TMSimpleStateTree simpleTree; - unsigned int tableSize; if (parseTree->numComplexBranchHeads) { TMComplexStateTree complexTree; complexTree = XtNew(TMComplexStateTreeRec); complexTree->isSimple = False; - tableSize = - (unsigned) (parseTree->numComplexBranchHeads * sizeof(StatePtr)); - complexTree->complexBranchHeadTbl = (StatePtr *) - __XtMalloc(tableSize); + complexTree->complexBranchHeadTbl = + XtMallocArray((Cardinal) parseTree->numComplexBranchHeads, + (Cardinal) sizeof(StatePtr)); memcpy(complexTree->complexBranchHeadTbl, - parseTree->complexBranchHeadTbl, tableSize); + parseTree->complexBranchHeadTbl, + parseTree->numComplexBranchHeads * sizeof(StatePtr)); complexTree->numComplexBranchHeads = parseTree->numComplexBranchHeads; simpleTree = (TMSimpleStateTree) complexTree; } @@ -1426,15 +1421,17 @@ _XtParseTreeToStateTree(TMParseStateTree parseTree) simpleTree->refCount = 0; simpleTree->mappingNotifyInterest = parseTree->mappingNotifyInterest; - tableSize = - (unsigned) (parseTree->numBranchHeads * sizeof(TMBranchHeadRec)); - simpleTree->branchHeadTbl = (TMBranchHead) __XtMalloc(tableSize); - memcpy(simpleTree->branchHeadTbl, parseTree->branchHeadTbl, tableSize); + simpleTree->branchHeadTbl = + XtMallocArray((Cardinal) parseTree->numBranchHeads, + (Cardinal) sizeof(TMBranchHeadRec)); + memcpy(simpleTree->branchHeadTbl, parseTree->branchHeadTbl, + parseTree->numBranchHeads * sizeof(TMBranchHeadRec)); simpleTree->numBranchHeads = parseTree->numBranchHeads; - tableSize = (unsigned) (parseTree->numQuarks * sizeof(XrmQuark)); - simpleTree->quarkTbl = (XrmQuark *) __XtMalloc(tableSize); - memcpy(simpleTree->quarkTbl, parseTree->quarkTbl, tableSize); + simpleTree->quarkTbl = XtMallocArray((Cardinal) parseTree->numQuarks, + (Cardinal) sizeof(XrmQuark)); + memcpy(simpleTree->quarkTbl, parseTree->quarkTbl, + parseTree->numQuarks * sizeof(XrmQuark)); simpleTree->numQuarks = parseTree->numQuarks; return (TMStateTree) simpleTree; diff --git a/src/Threads.c b/src/Threads.c index 566e71c..de3e38a 100644 --- a/src/Threads.c +++ b/src/Threads.c @@ -363,8 +363,7 @@ InitAppLock(XtAppContext app) #endif app_lock->stack.size = STACK_INCR; app_lock->stack.sp = -1; - app_lock->stack.st = - (struct _Tstack *) __XtMalloc(sizeof(struct _Tstack) * STACK_INCR); + app_lock->stack.st = XtMallocArray(STACK_INCR, sizeof(struct _Tstack)); for (ii = 0; ii < STACK_INCR; ii++) { app_lock->stack.st[ii].c = xcondition_malloc(); xcondition_init(app_lock->stack.st[ii].c); diff --git a/src/VarGet.c b/src/VarGet.c index 63930da..b377f07 100644 --- a/src/VarGet.c +++ b/src/VarGet.c @@ -246,7 +246,7 @@ XtVaGetValues(Widget widget, ...) if (total_count != typed_count) { size_t limit = (size_t) (total_count - typed_count); - args = (ArgList) __XtMalloc((unsigned) (limit * sizeof(Arg))); + args = XtMallocArray((Cardinal) limit, (Cardinal) sizeof(Arg)); } else args = NULL; /* for lint; really unused */ |