Mercurial > mxe-octave
annotate src/of-signal-1-fixes.patch @ 4733:1ecb1e67eaa1
* src/src-msys-dos2unix.mk: update checksum
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sat, 09 Jun 2018 10:13:46 -0400 |
parents | 85ac971a1bf0 |
children |
rev | line source |
---|---|
4702 | 1 # HG changeset patch |
2 # User Mike Miller <mtmiller@octave.org> | |
3 # Date 1525815613 25200 | |
4 # Node ID 3cbff3de1ebcb28a87ca0e0f8342ea393db19908 | |
5 # Parent 36e6b83ee1a1b178c58c14c5077038d7a6614118 | |
6 medfilt1: rewrite memory management, fix build error on MinGW (bug #53849) | |
7 | |
8 * medfilt1.cc (sorted_window::sorted_window): Make buf a unique_ptr. Use | |
9 member initialiation list. (sorted_window::~sorted_window): Delete. | |
10 (sorted_window::init): Use fill_n instead of bzero. (sorted_window::replace, | |
11 sorted_window::add, sorted_window::remove): Update syntax to dereference | |
12 offsets into buf. | |
13 | |
14 diff -r 36e6b83ee1a1 -r 3cbff3de1ebc src/medfilt1.cc | |
15 --- a/src/medfilt1.cc Sun May 06 10:17:15 2018 +0200 | |
16 +++ b/src/medfilt1.cc Tue May 08 14:40:13 2018 -0700 | |
17 @@ -27,9 +27,8 @@ | |
18 One dimensional median filter, for real double variables. | |
19 */ | |
20 | |
21 -//#ifdef HAVE_CONFIG_H | |
22 -//# include "config.h" | |
23 -//#endif | |
24 +#include <algorithm> | |
25 +#include <memory> | |
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
4591
diff
changeset
|
26 |
4702 | 27 #include "oct.h" |
28 #include "defun-dld.h" | |
29 @@ -44,7 +43,7 @@ | |
30 // Keeps NaNs at the "top" (after Inf) | |
31 class sorted_window | |
32 { | |
33 - double *buf; | |
34 + std::unique_ptr<double[]> buf; | |
35 octave_idx_type numel; | |
36 octave_idx_type numNaN; | |
37 bool nan_if_any_is; | |
38 @@ -70,16 +69,8 @@ | |
39 // If skip_nan then the median will consider only valid numbers within | |
40 // the window. | |
41 sorted_window (octave_idx_type width, bool skip_nan = true) | |
42 - { | |
43 - numel = 0; | |
44 - nan_if_any_is = ! skip_nan; | |
45 - buf = new double [width]; | |
46 - } | |
47 - | |
48 - ~sorted_window () | |
49 - { | |
50 - delete [] buf; | |
51 - } | |
52 + : buf (new double [width]), numel (0), numNaN (0), | |
53 + nan_if_any_is (! skip_nan) { } | |
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
4591
diff
changeset
|
54 |
4702 | 55 // Initialize to contain seed, and zeros additional zeros. |
56 void init (const double *seed, octave_idx_type num, octave_idx_type stride, | |
57 @@ -88,7 +79,7 @@ | |
58 numel = zeros; | |
59 numNaN = 0; | |
4591
50aebe534e42
of-signal: don't include octave/config.h in source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
4702 | 61 - bzero (buf, zeros * sizeof (double)); |
62 + std::fill_n (&buf[0], zeros, 0.0); | |
4591
50aebe534e42
of-signal: don't include octave/config.h in source files
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 |
4702 | 64 // Insert from seed. Could sort if it is large |
65 num *= stride; | |
66 @@ -106,7 +97,7 @@ | |
67 n_pos = find (next); | |
68 p_pos = find (prev, n_pos); | |
69 if (n_pos != p_pos) | |
70 - std::copy_backward (buf + n_pos, buf + p_pos, buf + p_pos + 1); | |
71 + std::copy_backward (&buf[n_pos], &buf[p_pos], &buf[p_pos + 1]); | |
72 } | |
73 else if (next > prev) | |
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
4591
diff
changeset
|
74 { |
4702 | 75 @@ -114,7 +105,7 @@ |
76 n_pos = find (next, p_pos); | |
77 if (n_pos != p_pos) | |
78 { | |
79 - std::copy (buf + p_pos + 1, buf + n_pos, buf + p_pos); | |
80 + std::copy (&buf[p_pos + 1], &buf[n_pos], &buf[p_pos]); | |
81 n_pos--; // position shifts due to deletion of p_pos | |
82 } | |
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
4591
diff
changeset
|
83 } |
4702 | 84 @@ -123,13 +114,13 @@ |
85 if (next == next) | |
86 { | |
87 n_pos = find (next); | |
88 - std::copy_backward (buf + n_pos, buf + numel - 1, buf + numel); | |
89 + std::copy_backward (&buf[n_pos], &buf[numel - 1], &buf[numel]); | |
90 numNaN--; | |
91 } | |
92 else if (prev == prev) | |
93 { | |
94 p_pos = find (prev); | |
95 - std::copy (buf + p_pos + 1, buf + numel, buf + p_pos); | |
96 + std::copy (&buf[p_pos + 1], &buf[numel], &buf[p_pos]); | |
97 n_pos = numel - 1; | |
98 numNaN++; | |
99 } | |
100 @@ -151,7 +142,7 @@ | |
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
4591
diff
changeset
|
101 { |
4702 | 102 n_pos = find (next); |
103 if (n_pos < numel) | |
104 - std::copy_backward (buf + n_pos, buf + numel, buf + numel + 1); | |
105 + std::copy_backward (&buf[n_pos], &buf[numel], &buf[numel + 1]); | |
4653
00e61c4a5657
fixes for package build errors due to API changes
John W. Eaton <jwe@octave.org>
parents:
4591
diff
changeset
|
106 } |
4702 | 107 else // NaN stored at end, so nothing to move. |
108 { | |
109 @@ -170,7 +161,7 @@ | |
110 if (prev == prev) | |
111 { | |
112 p_pos = find (prev); | |
113 - std::copy (buf + p_pos + 1, buf + numel, buf + p_pos); | |
114 + std::copy (&buf[p_pos + 1], &buf[numel], &buf[p_pos]); | |
115 } | |
116 else // NaN stored at end, so nothing to move. | |
117 numNaN--; | |
118 |