tmpSv = POPs; a_sv = newSVsv(tmpSv); // or use NEWSV/SvSetMagicSV #### void SglCreateProjectNameList() PPCODE: { char **names; int count,i; SglStatus ret; ret = SglCreateProjectNameList(NULL,&names,&count); if(ret != SGL_SUCCESS) XSRETURN_EMPTY; /* Here we take a belt and braces approach, the fact that we precalculate the length of the list (and call EXTEND) means that we could use PUSHs rather than XPUSHs, but it doesn't cost much to be paranoid */ EXTEND(SP,count+1); for(i = 0; i < count; i++) XPUSHs(sv_2mortal(newSVpvn(names[i], 1+strlen(names[i])))); SglFreeNameList(NULL,names); }