mem leak

[email protected] (ravips)
Newsgroups perl.xs
Organization http://groups.google.com
Message-ID <71df63e8-5d86-4628-a64a-52d783967f63@q35g2000yqn.googlegroups.com>
this is my sample xs code, which calls the C++ class to fetch details
of the person. The code works fine, i have couple of questions on
this, which would help me in identifying mem leaks with this piece of
code:

1. Should a "CLEANUP" tag be added which cleans up the array
( av_clear; av_undef;)?

2. Is the way hv is handled in the loop appropriate? Will it get
cleaned up appropriately?

 thanks.

==============================
AV *
perlWrapPers::GetDetails(name = NULL)
INPUT:
	char * name
PREINIT:
	AV *av;
	HV *hv;
	int size, i;
	pdetails_vector pv;
	int vect;
CODE:
        THIS->GetDetails(name,&pv);
	av =  (AV*)sv_2mortal((SV*)newAV());
	size = pv.size();
	for(i=0; i<size; i++) {
	        struct pdetails *pd;
		char *args;
	        hv = newHV();
	        pd = pv[i];
	        hv_store(hv, "name", 4, newSVpv(pd->name, strlen(pd->name)),
0);
	        hv_store(hv, "age", 3, newSVuv(pd->pid), 0);
	        av_push(av, newRV((SV *)hv));
	}
	for (vect = 0; vect < pv.size(); vect++)
	delete pv[vect];
	pv.clear();

        RETVAL = av;
OUTPUT:
        RETVAL
==============================
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.