Do you have an array of pointers?  If you want to delete just single
pointers, the normal version of delete will be fine.

I think it'd be better to use smart pointers, though.  I'd need to look at
the code to say for sure, however.

On Sat, Jul 4, 2020 at 9:43 PM Thomas <[email protected]> wrote:

> Here is my command: emcc --bind -o test.js C/keyGen/sources/test.cpp -s
> ENVIRONMENT='web' -s MODULARIZE=1 -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1
> -s SAFE_HEAP=1 -s DETERMINISTIC=1
>
> I experienced weird behaviors when deleting pointers in my C++ program...
> before I delete the pointer, it seems like the memory the pointer is
> pointing to has already corrupted.
>
>
> Do I need to call delete[] ptr if ptr is a class member variable?
>
> Weird things for me: If i try to delete the pointer after use, right
> before the delete[] ptr, the memory that the ptr is pointing to seems
> corrupted...If i don't delete it, the data stays consistent.
>
> Will dynamically allocated array defined in the C++ class be automatically
> freed after the class instance is deleted (or there is no function using
> it)?
>
> Can anybody explain to me how memory allocated for class member variable
> that is a pointer?
>
> Many thanks.
>
> --
> 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/7aaf1d72-30ff-4d6e-9cc1-bdf49c4b744ao%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/7aaf1d72-30ff-4d6e-9cc1-bdf49c4b744ao%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAC1De9GefNRZAqoGw7-y-FNy-mtsttxXHNKSZgFrrLZ_Gt7R_w%40mail.gmail.com.

Reply via email to