Re: Memory contents mysteriously changing
Mark wrote:
On Jan 23, 11:52 am, LR <lr...@superlink.net> wrote:
LR wrote:
Mark wrote:
Sorry, I forgot to ask about Silo.
Is this a C or a C++ library?
LR
Good question. As best I can tell by looking at the header file it's
a C library that is written to be compatible with C++.
I personally don't think it matters.
Will I run into memory allocation problems if I mix C and C++?
Not usually. Unless you try to 'delete' the pointer you got from
'malloc' (even indirectly), and it's a pointer to a class with a d-tor
or any members that might have a d-tor... Anyway, there is always more
than one way to get your program to have undefined behaviour, but it
does not stem from mixing languages. You can do it in a pure C++
program, it's simple, really.
> And is
there a way to check whether this is happening?
Whether memory problems are due to mixing languages? I don't think so.
Now, considering Kaz's and Pete's replies, try to find a good tool that
would help you identify the cause of the problem. The variations on the
cause are few. An array overrun, a dangling pointer, an uninitialised
pointer, an invalid (usually C-style) cast. That's probably not the
complete list, but close. Along with Kaz's recommendation of
'valgrind', I'd try turning up the warning level on your compiler,
running PC-lint on your source, and simplifying the code to try to
identify the place where it might happen: if you suspect SILO, start by
using their code samples first (supposing they work), then gradually add
to them what you've tested and verified as working (your code)...
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask