new & delete 
Author Message
 new & delete

I have a common problem.

I want to resize an array, but I don't know if this pointer exists or
how
big the array is right now.  I.E.

delete [] Array;
Array = new double [ArraySize];

How can I trap and correct for "trying to delete a non-existent array"
errors?

Pete

--
///////////////////////////
Peter B. O'Connor, Ph.D.
Scientist
IonSpec Corporation
16 Technology Drive, Suite 122
Irvine, California 92618-2325
Phone: (949) 753-1202 or (800) 438 - 3867
Fax: (949) 753 - 9121
//////////////////////////



Sun, 11 Feb 2001 03:00:00 GMT  
 new & delete
This may be too obvious, but initialize pArray to 0, and then set it back
to 0
after you do any deletes. Then test for 0 before you do a delete. I use
Win32's
GlobalReAlloc in these cases, so I don't have to copy over the data. You
might
look into using that for your case. - Doug S.
Quote:

> I have a common problem.

> I want to resize an array, but I don't know if this pointer exists or
> how
> big the array is right now.  I.E.

> delete [] Array;
> Array = new double [ArraySize];

> How can I trap and correct for "trying to delete a non-existent array"
> errors?

> Pete

> --
> ///////////////////////////
> Peter B. O'Connor, Ph.D.
> Scientist
> IonSpec Corporation
> 16 Technology Drive, Suite 122
> Irvine, California 92618-2325
> Phone: (949) 753-1202 or (800) 438 - 3867
> Fax: (949) 753 - 9121
> //////////////////////////



Sun, 11 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. new & delete

2. Error Using new & delete in class

3. new & delete on arrays

4. Overloading new & delete

5. Use of new & delete

6. ?malloc & free vs. new & delete

7. new & delete VS malloc & free

8. DLL's segmented heap, new() & delete() problem

9. multiply defined new & delete?

10. error when using delete & new in class

11. new&delete in different threads

12. new&delete - DLL with own heap...

 

 
Powered by phpBB® Forum Software