int value overwritten to zero sometimes
<p>I have a piece of code which works like this:</p>

<pre><code>boolQwInterface::setSomething(const A&amp; obj, const B&amp; Name, int Val)
{
    bool ret=true;

    LOG_MSG(msg, SIZE, "writing: %s, %s, %d", dbPtr-&gt;getDbName(), Name.getRepr().c_str(), Val);

    if(WriteDB(dbPtr-&gt;getid(), obj.c_string(), Name.getRepr().c_str(), (void*)&amp;Val)&lt;0)
    {
        LOG_MSG(msg, SIZE, "failed: %s", Name.getRepr().c_str());
        ret=false;
    }
    ....
}
</code></pre>

<p>The problem is "Val" is getting overwritten to 0 even though the caller is passing some genuine value like 40 or so. Sometimes, it take the right value the caller passes(like 40 or so), otherwise it takes it as zero though a value of 40 is being passed to it.
Any thoughts on this? May be I should be passing by reference?</p>
