segmentation fault - Why does Matlab crash when I use delete[]? -


i'm writing 2 matlab mex file handle persistent memory. want this

a *a = new a[n]; 

and free memory when i'm done using

delete[] a; 

this done using 2 separate mex function calls. problem delete[] statement crashes matlab segmentation fault. however, if reserve memory using malloc works fine:

a *a = (a *) malloc(n*sizeof(a)); = new(a) [n]; 

and when i'm done

free(a); 

any ideas why happens? proper way deal situation?

edit: looking @ code realize wasn't telling truth above. doing like

a *a = new b[n]; 

and then

delete[] a; 

where b derived a. have found out results in undefined behaviour...


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -