From: Tony Cook Date: Sun, 21 Feb 2016 01:17:05 +0000 (+1100) Subject: re-work malloc_temp(), calloc_temp() to avoid SV overhead X-Git-Tag: v1.004_001~20 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/3230a191553dd2bd44c2051b74941547e98a8132 re-work malloc_temp(), calloc_temp() to avoid SV overhead Previosly they created a temp SV and returned it's buffer. Now they just call Newx() or Newxz() and SAVEFREEPV() the result. --- diff --git a/Imager.xs b/Imager.xs index ccfcf0df..e16b42dd 100644 --- a/Imager.xs +++ b/Imager.xs @@ -124,15 +124,18 @@ Allocate memory that will be discarded when mortals are discarded. static void * malloc_temp(pTHX_ size_t size) { - SV *sv = sv_2mortal(newSV(size)); + void *result; + Newx(result, size, char); + SAVEFREEPV(result); - return SvPVX(sv); + return result; } static void * calloc_temp(pTHX_ size_t size) { - void *result = malloc_temp(aTHX_ size); - memset(result, 0, size); + void *result; + Newxz(result, size, char); + SAVEFREEPV(result); return result; }