Merge Richard Cohen's 'remove-unneeded-memcpy' into stable.

This commit is contained in:
John Ralls
2023-06-17 17:58:53 -07:00
10 changed files with 18 additions and 24 deletions

View File

@@ -1118,8 +1118,8 @@ gnc_sx_clone_temporal_state (SXTmpStateData *tsd)
if(tsd)
{
toRet = g_malloc(sizeof(SXTmpStateData));
toRet = memcpy (toRet, tsd, sizeof (SXTmpStateData));
toRet = g_new(SXTmpStateData, 1);
*toRet = *tsd;
}
return toRet;

View File

@@ -33,7 +33,6 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <string.h> /* for memcpy() */
#include <qofinstance-p.h>
#include "gncCustomerP.h"
@@ -399,7 +398,7 @@ void gncOwnerCopy (const GncOwner *src, GncOwner *dest)
{
if (!src || !dest) return;
if (src == dest) return;
memcpy (dest, src, sizeof (*dest));
*dest = *src;
}
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b)

View File

@@ -56,6 +56,7 @@
#include <boost/uuid/uuid_io.hpp>
#include <sstream>
#include <string>
#include <algorithm>
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = QOF_MOD_ENGINE;
@@ -120,7 +121,7 @@ guid_copy (const GncGUID *guid)
{
if (!guid) return nullptr;
auto ret = guid_malloc ();
memcpy (ret, guid, sizeof (GncGUID));
*ret = *guid;
return ret;
}
@@ -134,7 +135,7 @@ guid_null (void)
static void
guid_assign (GncGUID & target, gnc::GUID const & source)
{
memcpy (&target, &source, sizeof (GncGUID));
std::copy (source.begin(), source.end(), target.reserved);
}
/*Takes an allocated guid pointer and constructs it in place*/

View File

@@ -188,7 +188,7 @@ static QofQueryTerm * copy_query_term (const QofQueryTerm *qt)
if (!qt) return NULL;
new_qt = g_new0 (QofQueryTerm, 1);
memcpy (new_qt, qt, sizeof(QofQueryTerm));
*new_qt = *qt;
new_qt->param_list = g_slist_copy (qt->param_list);
new_qt->param_fcns = g_slist_copy (qt->param_fcns);
new_qt->pdata = qof_query_core_predicate_copy (qt->pdata);
@@ -224,7 +224,7 @@ copy_or_terms(const GList * or_terms)
static void copy_sort (QofQuerySort *dst, const QofQuerySort *src)
{
memcpy (dst, src, sizeof (*dst));
*dst = *src;
dst->param_list = g_slist_copy (src->param_list);
dst->param_fcns = g_slist_copy (src->param_fcns);
}
@@ -1006,7 +1006,7 @@ QofQuery * qof_query_copy (QofQuery *q)
ht = copy->be_compiled;
free_members (copy);
memcpy (copy, q, sizeof (QofQuery));
*copy = *q;
copy->be_compiled = ht;
copy->terms = copy_or_terms (q->terms);