Hi I am new to XS but have coded for perl and C for a few year. Maybe this question sounds stupid but I can not figure it out on perlgut and perlxs at the moment.
I have an array which contains several reference of new created hashes. I know that if I use method newRV_noinc for av_push in construction stage, the reference to each hash is 1. After the code does some stuff, I need to clear the array as I want to refill it. I have made my code in a concise example as following. Now I wonder whether av_clear will decrement the reference number of hash1 and hash2 to 0. If it does, then hash would be destroyed automatically, else I have to destroy it explicitly to avoid memory leak. Could anyone point it out for me? ========================================================================================== int size1 = 20; int size2 = 21; char name1[] = "foo1"; char name2[] = "foo2"; HV *hash1 = newHV(); hv_store(hash1, "name", strlen("name"), newSVpv(name1,0), 0); hv_store(hash1, "size", strlen("size"), newSViv(size1), 0); av_push(array, newRV_noinc((SV*)hash1)); //reference to hash1 is 1 HV *hash2 = newHV(); hv_store(hash2, "name", strlen("name"), newSVpv(name2,0), 0); hv_store(hash2, "size", strlen("size"), newSViv(size2), 0); av_push(array, newRV_noinc((SV*)hash2)); //reference to hash2 is 1 ....... av_clear(array); //whether reference number of hash1 and hash2 decremented here??