Funky new problems?
im not elite with C++(this does not apply to my C knowledge) but on occasion I use the operator new instead of *alloc, and i stangely get Illegal Operations which can be better illistrated with a text example!
ok, i have a functioning class in it i allocate memory which is used through-out the program and deleted in the destructor. i use new being sure to allocate enough memory(eg. the exact size to be used), when i "delete" the memory or after the program exits i get an illegal operation, but heres the catch if i allocate a bunch more memory it doesn't happen! so you say "hes overwriting the memory and causing it not to delete properly" which is what i thought at first, then i checked it out and I wasn't so i replaced it with a call to malloc and released it with free with the exact code as with the new and it works!
so im i using new improperly or do i suffer a compiler implementation bug?
That happens to me too, and I'm not sure why...
Have you a, (short), program which demonstrates the effect you could post. I'll try it and see if it is a compiler issue, (probably not!), or if I can see if you're doing something wrong.
I don't tend to have this problem.
I'm assuming here, but are you overloading the new operator?
There can be problems if you overload new and then release the memory with a call to the standard operator delete......
If you are overloading new, then overload delete as well.....
As I said I am assuming here....
>I'll try it and see if it is a compiler issue, (probably not!), or if I can see if you're doing something wrong.
im assuming it's me,
this is a snippet from part of a program that loads a lwo(3D file) into memory,
where chunksize is declared
int chunksize = 0;
and later has a value of 120(bytes)
PointList is declared in the class like so
PointList = new float[chunksize/4];
for(int i = 0;i < chunksize/4;i++)
and is deleted like this
if(PointList != NULL)
well when i used this i got illegal operation on program close, but since this debugger can act a little funny it may also be the delete.
im using malloc() with the SAME EXACT code and its fine.
well **** now i try it with new and its fine, must be a compiler bug...or im retarded(more likely)...