summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-11 19:02:20 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-08-11 19:03:57 -0700
commit1aaf5d502027104ddd566090787780319f510278 (patch)
treeaaa11a76874c427ae4e8a15551a3c4ac1abce7c2
parent3c54e99864eb6dba0d0cde7fe0a23ed7c1f5875f (diff)
Use memcpy() instead of XtMemmove() when buffers are known to differ
Most of these came from a mass XtBCopy() -> XtMemmove() substitution in 1993 with a commit comment of "ANSIfication". But include/X11/IntrinsicI.h now defines XtMemmmove() as just calling memcpy() as long as src & dst differ, so remove an unnecessary check when we've just allocated a buffer, and reduce the chance that someone thinks we'll actually call memmove() instead of memcpy() Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/Resources.c2
-rw-r--r--src/TMaction.c3
-rw-r--r--src/TMstate.c29
3 files changed, 16 insertions, 18 deletions
diff --git a/src/Resources.c b/src/Resources.c
index d8ea4fc..15a78c2 100644
--- a/src/Resources.c
+++ b/src/Resources.c
@@ -377,7 +377,7 @@ _XtDependencies(XtResourceList *class_resp, /* VAR */
new_res = (XrmResourceList *)
__XtMalloc((Cardinal) (new_num_res * sizeof(XrmResourceList)));
if (super_num_res > 0)
- XtMemmove(new_res, super_res, super_num_res * sizeof(XrmResourceList));
+ memcpy(new_res, super_res, super_num_res * sizeof(XrmResourceList));
/* Put pointers to class resource entries into new_res */
new_next = super_num_res;
diff --git a/src/TMaction.c b/src/TMaction.c
index 908ca61..fad1714 100644
--- a/src/TMaction.c
+++ b/src/TMaction.c
@@ -471,8 +471,7 @@ EnterBindCache(Widget w,
}
_XtGlobalTM.bindCacheTbl[_XtGlobalTM.numBindCache++] = bindCache;
#endif /* TRACE_TM */
- XtMemmove((XtPointer) &bindCache->procs[0],
- (XtPointer) procs, procsSize);
+ memcpy(&bindCache->procs[0], procs, procsSize);
}
UNLOCK_PROCESS;
return &bindCache->procs[0];
diff --git a/src/TMstate.c b/src/TMstate.c
index e0414ca..e9edbd4 100644
--- a/src/TMstate.c
+++ b/src/TMstate.c
@@ -140,7 +140,7 @@ GetBranchHead(TMParseStateTree parseTree,
TMBranchHead oldBranchHeadTbl = parseTree->branchHeadTbl;
parseTree->branchHeadTbl = (TMBranchHead) __XtMalloc(newSize);
- XtMemmove(parseTree->branchHeadTbl, oldBranchHeadTbl, newSize);
+ memcpy(parseTree->branchHeadTbl, oldBranchHeadTbl, newSize);
parseTree->isStackBranchHeads = False;
}
else {
@@ -195,7 +195,7 @@ _XtGetQuarkIndex(TMParseStateTree parseTree, XrmQuark quark)
XrmQuark *oldquarkTbl = parseTree->quarkTbl;
parseTree->quarkTbl = (XrmQuark *) __XtMalloc(newSize);
- XtMemmove(parseTree->quarkTbl, oldquarkTbl, newSize);
+ memcpy(parseTree->quarkTbl, oldquarkTbl, newSize);
parseTree->isStackQuarks = False;
}
else {
@@ -242,8 +242,8 @@ GetComplexBranchIndex(TMParseStateTree parseTree,
StatePtr *oldcomplexBranchHeadTbl = parseTree->complexBranchHeadTbl;
parseTree->complexBranchHeadTbl = (StatePtr *) __XtMalloc(newSize);
- XtMemmove(parseTree->complexBranchHeadTbl,
- oldcomplexBranchHeadTbl, newSize);
+ memcpy(parseTree->complexBranchHeadTbl,
+ oldcomplexBranchHeadTbl, newSize);
parseTree->isStackComplexBranchHeads = False;
}
else {
@@ -1421,8 +1421,8 @@ _XtParseTreeToStateTree(TMParseStateTree parseTree)
(unsigned) (parseTree->numComplexBranchHeads * sizeof(StatePtr));
complexTree->complexBranchHeadTbl = (StatePtr *)
__XtMalloc(tableSize);
- XtMemmove(complexTree->complexBranchHeadTbl,
- parseTree->complexBranchHeadTbl, tableSize);
+ memcpy(complexTree->complexBranchHeadTbl,
+ parseTree->complexBranchHeadTbl, tableSize);
complexTree->numComplexBranchHeads = parseTree->numComplexBranchHeads;
simpleTree = (TMSimpleStateTree) complexTree;
}
@@ -1436,14 +1436,13 @@ _XtParseTreeToStateTree(TMParseStateTree parseTree)
tableSize =
(unsigned) (parseTree->numBranchHeads * sizeof(TMBranchHeadRec));
- simpleTree->branchHeadTbl = (TMBranchHead)
- __XtMalloc(tableSize);
- XtMemmove(simpleTree->branchHeadTbl, parseTree->branchHeadTbl, tableSize);
+ simpleTree->branchHeadTbl = (TMBranchHead) __XtMalloc(tableSize);
+ memcpy(simpleTree->branchHeadTbl, parseTree->branchHeadTbl, tableSize);
simpleTree->numBranchHeads = parseTree->numBranchHeads;
tableSize = (unsigned) (parseTree->numQuarks * sizeof(XrmQuark));
simpleTree->quarkTbl = (XrmQuark *) __XtMalloc(tableSize);
- XtMemmove(simpleTree->quarkTbl, parseTree->quarkTbl, tableSize);
+ memcpy(simpleTree->quarkTbl, parseTree->quarkTbl, tableSize);
simpleTree->numQuarks = parseTree->numQuarks;
return (TMStateTree) simpleTree;
@@ -1883,8 +1882,8 @@ MakeBindData(TMComplexBindProcs bindings,
if (oldBindData && oldBindData->simple.isComplex)
cBindData->accel_context =
((TMComplexBindData) oldBindData)->accel_context;
- XtMemmove((char *) &cBindData->bindTbl[0], (char *) bindings,
- numBindings * sizeof(TMComplexBindProcsRec));
+ memcpy(&cBindData->bindTbl[0], bindings,
+ numBindings * sizeof(TMComplexBindProcsRec));
}
return bindData;
}
@@ -2074,9 +2073,9 @@ _XtGetTranslationValue(Widget w)
aXlations->hasBindings = True;
aXlations->xlations = xlations;
aXlations->next = NULL;
- XtMemmove((char *) &aXlations->bindTbl[0],
- (char *) &cBindData->bindTbl[0],
- numBindings * sizeof(TMComplexBindProcsRec));
+ memcpy(&aXlations->bindTbl[0],
+ &cBindData->bindTbl[0],
+ numBindings * sizeof(TMComplexBindProcsRec));
return (XtTranslations) aXlations;
}
}