[gnumeric] Use go_memdup_n where appropriate.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Use go_memdup_n where appropriate.
- Date: Fri, 3 Dec 2021 00:55:02 +0000 (UTC)
commit 0604022786791aa85f7dd96625255ea3d2a866fc
Author: Morten Welinder <terra gnome org>
Date: Thu Dec 2 19:54:17 2021 -0500
Use go_memdup_n where appropriate.
plugins/fn-stat/functions.c | 4 ++--
plugins/fn-tsa/functions.c | 4 ++--
plugins/lotus-123/lotus.c | 2 +-
plugins/nlsolve/gnm-nlsolve.c | 2 +-
plugins/openoffice/openoffice-read.c | 2 +-
src/collect.c | 8 ++++----
src/tools/gnm-solver.c | 2 +-
src/widgets/gnm-expr-entry.c | 2 +-
8 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index d98377b33..f98b63ce9 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -3308,7 +3308,7 @@ calc_ttest_paired (gnm_float const *xs, gnm_float const *ys, int n,
return 1;
/* zs = xs - ys */
- zs = go_memdup (xs, n * sizeof (*xs));
+ zs = go_memdup_n (xs, n, sizeof (*xs));
for (i = 0; i < n; i++)
zs[i] -= ys[i];
@@ -4344,7 +4344,7 @@ gnumeric_growth (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
goto out;
} else {
/* @{new_x}'s is assumed to be the same as @{known_x}'s */
- nxs = go_memdup (xs, n * sizeof (gnm_float));
+ nxs = go_memdup_n (xs, n, sizeof (gnm_float));
nnx = n;
}
diff --git a/plugins/fn-tsa/functions.c b/plugins/fn-tsa/functions.c
index dd2a2a71d..16878f542 100644
--- a/plugins/fn-tsa/functions.c
+++ b/plugins/fn-tsa/functions.c
@@ -488,8 +488,8 @@ gnumeric_interpolation (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (!gnm_range_increasing (vals0, n0)) {
gboolean switched = TRUE;
if (constp) {
- vals0 = go_memdup (vals0, sizeof(gnm_float) * n0);
- vals1 = go_memdup (vals1, sizeof(gnm_float) * n0);
+ vals0 = go_memdup_n (vals0, n0, sizeof(gnm_float));
+ vals1 = go_memdup_n (vals1, n0, sizeof(gnm_float));
constp = FALSE;
}
while (switched) {
diff --git a/plugins/lotus-123/lotus.c b/plugins/lotus-123/lotus.c
index 8852d0fc9..757ab4157 100644
--- a/plugins/lotus-123/lotus.c
+++ b/plugins/lotus-123/lotus.c
@@ -1042,7 +1042,7 @@ lotus_rldb_new (int ndims, const int *dims, LotusRLDB *top)
g_printerr (") rldb.\n");
#endif
top = res;
- res->dims = go_memdup (dims, ndims * sizeof (*dims));
+ res->dims = go_memdup_n (dims, ndims, sizeof (*dims));
res->definitions = g_hash_table_new_full
(g_direct_hash,
g_direct_equal,
diff --git a/plugins/nlsolve/gnm-nlsolve.c b/plugins/nlsolve/gnm-nlsolve.c
index edfc37c0a..623936e02 100644
--- a/plugins/nlsolve/gnm-nlsolve.c
+++ b/plugins/nlsolve/gnm-nlsolve.c
@@ -363,7 +363,7 @@ rosenbrock_iter (GnmNlsolve *nl)
: gnm_abs (isol->xk[i]) * eps;
}
- xkm1 = go_memdup (isol->xk, n * sizeof (gnm_float));
+ xkm1 = go_memdup_n (isol->xk, n, sizeof (gnm_float));
state = g_new0 (char, n);
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 0eb47645d..4536e0f97 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -14362,7 +14362,7 @@ create_preparse_dtd (const GsfXMLInNode *orig, const GsfXMLInNode *overrides)
}
- res = go_memdup (orig, (N + 1) * sizeof (GsfXMLInNode));
+ res = go_memdup_n (orig, N + 1, sizeof (GsfXMLInNode));
for (i = 0; i < N; i++) {
res[i].start = NULL;
res[i].end = NULL;
diff --git a/src/collect.c b/src/collect.c
index 773cc9511..18de73e0b 100644
--- a/src/collect.c
+++ b/src/collect.c
@@ -472,7 +472,7 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
*constp = TRUE;
return ce->data;
}
- return go_memdup (ce->data, *n * sizeof (gnm_float));
+ return go_memdup_n (ce->data, *n, sizeof (gnm_float));
}
}
@@ -531,7 +531,7 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
*constp = TRUE;
ce->data = cl.data;
} else
- ce->data = go_memdup (cl.data, MAX (1, *n) * sizeof (gnm_float));
+ ce->data = go_memdup_n (cl.data, MAX (1, *n), sizeof (gnm_float));
prune_caches ();
/*
@@ -857,8 +857,8 @@ collect_float_pairs (GnmValue const *vx, GnmValue const *vy,
*xs1 = ce->data_y;
*constp = TRUE;
} else {
- *xs0 = go_memdup (ce->data_x, *n * sizeof (gnm_float));
- *xs1 = go_memdup (ce->data_y, *n * sizeof (gnm_float));
+ *xs0 = go_memdup_n (ce->data_x, *n, sizeof (gnm_float));
+ *xs1 = go_memdup_n (ce->data_y, *n, sizeof (gnm_float));
}
} else {
if (constp)
diff --git a/src/tools/gnm-solver.c b/src/tools/gnm-solver.c
index e80ce5fb8..b7981fbdb 100644
--- a/src/tools/gnm-solver.c
+++ b/src/tools/gnm-solver.c
@@ -3585,7 +3585,7 @@ gnm_iter_solver_set_solution (GnmIterSolver *isol)
result->quality = GNM_SOLVER_RESULT_FEASIBLE;
result->value = sol->flip_sign ? 0 - isol->yk : isol->yk;
- result->solution = go_memdup (isol->xk, n * sizeof (gnm_float));
+ result->solution = go_memdup_n (isol->xk, n, sizeof (gnm_float));
g_object_set (sol, "result", result, NULL);
g_object_unref (result);
diff --git a/src/widgets/gnm-expr-entry.c b/src/widgets/gnm-expr-entry.c
index 62d552f45..3165c2a2d 100644
--- a/src/widgets/gnm-expr-entry.c
+++ b/src/widgets/gnm-expr-entry.c
@@ -1069,7 +1069,7 @@ gee_duplicate_lexer_items (GnmLexerItem *gli)
n++;
}
- return go_memdup (gli, n * sizeof (GnmLexerItem));
+ return go_memdup_n (gli, n, sizeof (GnmLexerItem));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]