stil memory deallocation error...
@@ -3,7 +3,7 @@ | ||
3 | 3 | SRCS=test_particle.cc test_particles.cc test_filter.cc |
4 | 4 | OBJS=$(SRCS:.cc=.o) |
5 | 5 | TARGETS=$(SRCS:.cc=) |
6 | -CFLAGS=-I/usr/local/include/cutter -I. -I../src | |
6 | +CFLAGS=-I/usr/local/include/cutter -I. -I../src -g | |
7 | 7 | LDFLAGS=@LDFLAGS@ -L. -L../src -lparticle -lcppcutter |
8 | 8 | all: $(TARGETS) |
9 | 9 |
@@ -4,11 +4,12 @@ | ||
4 | 4 | #include <filter.h> |
5 | 5 | using namespace std; |
6 | 6 | |
7 | -static Particles func() | |
7 | +static Particles func(Particles &p) | |
8 | 8 | { |
9 | - Particles a; | |
9 | +// Particles a(5,3); | |
10 | +// Particles a; | |
10 | 11 | cout<<"state function"<<endl; |
11 | - return(a); | |
12 | + return(p); | |
12 | 13 | } |
13 | 14 | |
14 | 15 | namespace test_filter |
@@ -29,6 +30,7 @@ | ||
29 | 30 | a.createInitialParticles(); |
30 | 31 | a.dump_predict_particles(); |
31 | 32 | a.set_state_func(&func); |
32 | - a.get_next_state(); | |
33 | + Particles b; | |
34 | + a.get_next_state(b); | |
33 | 35 | } |
34 | 36 | } |
@@ -5,7 +5,7 @@ | ||
5 | 5 | HEADS=$(SRCS:.cc=.h) |
6 | 6 | TARGETS=libparticle.so |
7 | 7 | AR=@AR@ |
8 | -CFLAGS=-I. | |
8 | +CFLAGS=-I. -g | |
9 | 9 | all: $(TARGETS) |
10 | 10 | |
11 | 11 | libparticle.so: $(OBJS) |
@@ -9,7 +9,7 @@ | ||
9 | 9 | } |
10 | 10 | Filter::~Filter() |
11 | 11 | { |
12 | - if(x) delete x; | |
12 | +// if(x) delete x; | |
13 | 13 | } |
14 | 14 | |
15 | 15 | bool Filter::setNumber(int n) |
@@ -31,14 +31,14 @@ | ||
31 | 31 | x->dump_particles(); |
32 | 32 | return(0); |
33 | 33 | } |
34 | -bool Filter::set_state_func(Particles (*func)()) | |
34 | +bool Filter::set_state_func(Particles (*func)(Particles &p)) | |
35 | 35 | { |
36 | 36 | state_func = func; |
37 | 37 | return(true); |
38 | 38 | } |
39 | -Particles Filter::get_next_state() | |
39 | +Particles Filter::get_next_state(Particles &p) | |
40 | 40 | { |
41 | 41 | cout<<"go..."<<endl; |
42 | - (*state_func)(); | |
42 | + (*state_func)(p); | |
43 | 43 | cout<<"ok..."<<endl; |
44 | 44 | } |
@@ -11,7 +11,7 @@ | ||
11 | 11 | Particles *x; |
12 | 12 | vector<int> y; |
13 | 13 | int number, dimension; |
14 | - Particles (*state_func)(); | |
14 | + Particles (*state_func)(Particles &p); | |
15 | 15 | public: |
16 | 16 | Filter(); |
17 | 17 | ~Filter(); |
@@ -19,8 +19,8 @@ | ||
19 | 19 | bool setDimension(int d); |
20 | 20 | bool createInitialParticles(); |
21 | 21 | int dump_predict_particles(); |
22 | - bool set_state_func(Particles (*func)()); | |
23 | - Particles get_next_state(); | |
22 | + bool set_state_func(Particles (*func)(Particles &p)); | |
23 | + Particles get_next_state(Particles &p); | |
24 | 24 | }; |
25 | 25 | |
26 | 26 | #endif |
@@ -5,7 +5,7 @@ | ||
5 | 5 | HEADS=$(SRCS:.cc=.h) |
6 | 6 | TARGETS=libparticle.so |
7 | 7 | AR=ar |
8 | -CFLAGS=-I. | |
8 | +CFLAGS=-I. -g | |
9 | 9 | all: $(TARGETS) |
10 | 10 | |
11 | 11 | libparticle.so: $(OBJS) |