Hi,

I have an Embind interface to native code for transcoding textures that needs 
to return the, potentially large, array containing the transcoded texture. 
Currently it does this:

            std::vector<uint8_t> dst;
            
dst.resize(getTranscodedImageByteLength(static_cast<transcoder_texture_format>(cTargetFormat),
                                                    width, height));

            // code to fill dst with the transcoded image ...

            val ret = val::object();
            ret.set("error", static_cast<uint32_t>(error));
            if (error == KTX_SUCCESS) {
                // FIXME: Who deletes dst and how?
                ret.set("transcodedImage", typed_memory_view(dst.size(), 
dst.data()));
            }
            return std::move(ret);
        }

This is broken. Successive calls overwrite the image returned in earlier calls. 
Obviously this can be fixed by copying the data but I don’t want to do that. 
Can I replace

            std::vector<uint8_t> dst;

with

            std::vector<uint8_t> dst = new std::vector<uint8_t>;

If so, how does the receiving JS side free the memory when done with it? The 
Emscripten documentation says to use `.delete()` but on what you call that is 
not made clear. Also will I need to add an Emscripten compile option to allow 
memory growth if I use `new`?

Regards

    -Mark

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/F1E70CB8-3B41-4EF0-9BCD-49E6E780D74A%40callow.im.

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to