Re: realloc in function
From: Alexander Grigoriev (alegr_at_earthlink.net)
Date: 02/05/05
- Next message: Frank Hickman [MVP]: "Re: How do i convert unsigned char to Hex Value"
- Previous message: H.B.: "Problem to receive UDP packet with Checksum not computed ..."
- In reply to: Ryan Rogers: "Re: realloc in function"
- Next in thread: Igor Tandetnik: "Re: realloc in function"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 4 Feb 2005 21:47:12 -0800
This line pointed to one of your errors:
set1 = (int*)realloc(set1, *sizeSet1 * sizeof(int));
Note '&' removed before 'set1' argument.
My note about memory leak is also very important for proper use of realloc.
You should heed those who have mastered the language use, for they see the
'little' errors, which directly affect your code quality. You may have lots
of credentials in your field, but if you want to write software, listen to
professionals.
I'd recommend you to read "Code complete", by Steve McConnell.
"Ryan Rogers" <westhillian@hotmail.com> wrote in message
news:%23eJ9%230mCFHA.3976@tk2msftngp13.phx.gbl...
>
> First and foremost you know nothing about how I am in class. Some
> facts, since you seem pretty keen on speculating, are that I am on
> honours and I do go far beyond what the professors teach and expect from
> me. I sit on the dean's administrative counsel, and was senator for the
> school of Applied Computing and Engineering sciences oh and I've won a
> few awards, SSUI appreciation and the board of governors' appreciation
> award. I also have no problem in getting tech positions in my field,
> Magna, GlaxoSmithKline and RIM are among my latest contracts. Trust me I
> have the aptitude to take myself far regardless of what you state here
> in your petty assumptions to try to slander me.
>
> My initial question was not answered (to summarize): 'why do the
> values of my passed array incorrect when I return to the main function.'
> The response was
>
> " set1 = (int*)realloc(set1, *sizeSet1 * sizeof(int));
>
>
>
> Keep in mind that assigning realloc result to the same pointer may lead
> to memory leak, in case the allocation fails."
>
> Heck this isn't even an answer, but a statement about assigning realloc
> to the same point, legal but wrong; regardless still not the answer to
> my specific question.
>
> My question did fall into the correct category IMHO because I don't see
> a Microsoft.public.vc.memory listed. My desire to use C is also not
> misplaced, you're really bad at this assuming game, the course title is
> Systems Programming in C, not C++.
>
> "The post to which I replied had no such statement. Perhaps
> you are not yet aware that your posting have a very limited
> lifetime on many news servers."
>
> Why would you read Microsoft news from anywhere other then the MS news
> server or Google?
>
> As for being ignorant about the criteria of an MVP, I'll let curious
> readers decided.
>
> " MVPs earn their status by being nominated by peers and Microsoft
> Managers who see their consistent and accurate technical answers posted
> in the forums. The volunteer spirit of the MVPs and their positive
> online contribution helps create strong communities." -
> http://www.microsoft.com/india/mvp/default.aspx
>
> You're not going to be nominated with smart-ass responses
> Your sprit is not positive.
> Hmm guess I was right.
>
>
>
- Next message: Frank Hickman [MVP]: "Re: How do i convert unsigned char to Hex Value"
- Previous message: H.B.: "Problem to receive UDP packet with Checksum not computed ..."
- In reply to: Ryan Rogers: "Re: realloc in function"
- Next in thread: Igor Tandetnik: "Re: realloc in function"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|