Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!moray!urchin!f506.n106.z1.fidonet.org!Roy.Browning From: Roy.Browning@f506.n106.z1.fidonet.org (Roy Browning) Newsgroups: comp.lang.c++ Subject: Re: lint++ -> really "AutoCodeReview" -- Ideas requested. Message-ID: <5866.2587A9E2@urchin.fidonet.org> Date: 14 Dec 89 04:54:28 GMT Sender: ufgate@urchin.fidonet.org (newsout1.26) Organization: FidoNet node 1:106/506 - Fulcrum's Edge, Spring TX Lines: 47 > > > ComIdent::~ComIdent() > > > { > > > if ( string ) > > > delete[strlen(string)+1] string; > > > } > Actually, delete[X] p; is used when p points at an > array of X objects with destructors. It calls the > destructor on each of the X objects but only passes > "p" to free() (or the equivalent function.) > > Since 'char' doesn't have a destructor, the above > code is equivalent to just 'delete string;' Joe: Ouch, guess I deserved that. Couched my answer in very loose 'C' jargon in the C++ newsgroup and got my head handed to me . I habitually use imprecise terminology relying on the overall meaning rather than the exact words. Will have to revert to a policy of only posting tested code. Spent a couple of hours proving that the code below would loose random pointers to free(). Even modified my library to to demonstrate exactly what was occurring. main() { char* str = "Test string"; String* a = (String*) new String; *a = str; cout << a; delete[5] a; exit(0); } Then I looked at your reply and the original message and observed that I had only proven that I had misread the original missive. You are quite correct, "delete[x] string" calls free only once deallocating the string. I stand corrected, Roy Browning