keith_k

Working with PDS objects in Perl SDK

Discussion created by keith_k on Apr 23, 2009
Latest reply on Apr 25, 2009 by keith_k
(This is probably a question for someone at Nimsoft, but anyone can share any insights they might have...)

I have been using the Perl SDK for a while and am very comfortable with it for the most part. Due to a bug in the Perl SDK, I was never able to use the pdsDelete() function to clean up my memory usage. Now that the bug is fixed, I am interested in keeping my scripts clean. It also appears a new script is crashing, so I want to find out how I should be handing memory.

Here is some example Perl that shows what I am doing so far:
my $pds_snd = pdsCreate();
pdsPut_PCH($pds_snd, $key1, $value1);
pdsPut_PCH($pds_snd, $key2, $value2);
pdsPut_INT($pds_snd, $key3, $value3);
my ($rc, $pds_rcv) = nimSessionRequest($sess, $cmd, $pds_snd, 60);

if ( $rc ) {
    nimLog(0, "ERROR $cmd: " . nimError2Txt($rc)) if $logerr;
    return undef;
}
return Nimbus::smileytongue:DS->new($pds_rcv)->asHash();
(I actually use nimNamedRequest() more than nimSessionRequest(), but this happens to be what I am using in my current script.) I really just want to return the hash, but I need to convert the PDS data structure to a PDS object to get access to the asHash() function.

Question 1: Can I use pdsDelete($pds_snd) immediately after the nimSessionRequest() call? I assume I should delete that PDS, since I create it with pdsCreate().

Question 2: Even though $pds_rcv came from nimSessionRequest() rather than a pdsCreate(), should I still use pdsDelete() on it before returning? (I would have to create a variable for the hash so that I can still return the hash.)

I also have a question about the following line of code that makes a PDS object from a PDS data structure:
$pds_obj = Nimbus::smileytongue:DS->new($pds_ds);
Question 3: After that line, are $pds_ds and $pds_obj linked in some way? Or are they two independent items that contain the same data? Could $pds_ds be deleted after this and leave $pds_obj around?

I think that is all of my questions for now...  :-)

Thanks,
Keith

Outcomes