[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] gsl_vector memory management help
From: |
Noel du Toit |
Subject: |
[Help-gsl] gsl_vector memory management help |
Date: |
Mon, 26 Jul 2010 16:39:48 -0700 |
Hello,
I have two classes: myClass_t and myMember_t. The myClass_t has a member
variable of type myMember_t (called member). The myMember_t has a member of
type gsl_vector* (called v), for which memory gets allocated in the myMember_t
constructor, and the memory is freed in the myMember_t destructor.
I want to assign the some other variable of type myMember_t (called mM) to the
myMember_t member in myClass_t, so I wrote an assignment operator for
myMember_t to copy the elements of the gsl_vector.
My problem is that when I call the assignment operator directly everything
works ok, but this requires public variables. However, when I write a mutator
function for myClass_t (called setMember):
1) the variable that I pass in (mM) gets corrupted, even though the myClass_t
member get correctly updated
2) the local variable mM cannot be de-allocated.
I am pretty new to C++, but as far as I can tell the memory allocation is
correct, so I think it is my lack of understanding of the memory management on
gsl_vector side that is causing this (hence the email to this list). Any help
will be appreciated. Attached is the source code that I use, with the compile
command at the top of the file.
Thanks,
Noel
test.cc
Description: Binary data
- [Help-gsl] gsl_vector memory management help,
Noel du Toit <=