My apologies if this is obvious to anyone but me, but I have this piece of code in my extension files…
for (int ly = (height - 1); ly >= 0; ly--) {
for (int lx = 0; lx < width; lx++) {
if ((lx < (aw+offx)) && (ly < (ah+offy)) && (lx >= offx) && (ly >= offy)) {
ox = number(lx-offx);
oy = number(ly-offy);
oyy = cons(oy, NULL);
subscripts = cons(ox, oyy);
element = getarray(array, subscripts, env, &bit);
*element = number(readBGR(file));
myfree(subscripts);
myfree(oyy);
myfree(oy);
myfree(ox);
}
else {
file.read();
file.read();
file.read();
}
}
//ignore trailing zero bytes
if (zpad > 0) {
for (int i = 0; i < zpad; i++) {
file.read();
}
}
}
… where ox, oy, oyy and subscripts are declared as object* / object**. Is it necessary or even a mistake to use myfree on these in each iteration? Could/should I just mutate and thus re-use the pointers and omit myfree? Note that I need to cons oyy and subscripts for every pixel position.