Pointer-to-pointer realloc problem

H

Herhor

Hello marvinla!

See how these old drags got carried away on my advise. It is quite
clear they are _too backward persons_ to be able to think progressively.
They suggested you to use almost forty years old malloc/free shit if
there is _much simpler and secure_ new/delete alternative. It isn't done
without reason because otherwise these buzzards would have to *close*
their antiquated newsgroup and move themselves into some *software
museum* like this at: http://dn.codegear.com/museum. :)

So blow off them and do as I advocated you!
 
A

Army1987

Duncan Muirhead said:
*(p+1)+1 is the same as *p+2 which is the same as *(p+2), so
*(*(p+1)+1) is the same as **(p+2). I suspect you wanted *((*(p+1))+1)
Huh?
*(p + 1) + 1 is p[1] + 1, *p + 2 is p[0] + 2, and *(p + 2) is p[2].
*(*(p+1)+1) is p[1][1], and **(p + 2) is p[2][0].
 
R

Richard Heathfield

Herhor said:
Hello marvinla!

See how these old drags got carried away on my advise.

Nope. They just pointed out that you're wrong, which you are.
It is quite
clear they are _too backward persons_ to be able to think
progressively.

If "think progressively" == "think wrongly", then you might have a
point, but it doesn't, and you don't.

You are, quite simply, incorrect. Learn how to learn from corrections.
 
M

mark_bluemel

[Something that probably translates as "I is 133t!"]

I'm currently classifying this guy as a troll unless/until I see
evidence to the contrary.
 
M

marvinla

Hello marvinla!

See how these old drags got carried away on my advise. It is quite
clear they are _too backward persons_ to be able to think progressively.
They suggested you to use almost forty years old malloc/free shit if
there is _much simpler and secure_ new/delete alternative. It isn't done
without reason because otherwise these buzzards would have to *close*
their antiquated newsgroup and move themselves into some *software
museum* like this at:http://dn.codegear.com/museum. :)

So blow off them and do as I advocated you!

Herhor,
I'm writing my code in C, not in C++. I know about the new and delete
in C++, and
IF I was using C++, of course I would use them.

See you, and thank you guys for the great explanations!
 
C

CBFalconer

Ben said:
.... snip ...

In your suggested pattern, the name 'attemptcorrection' is rather
misleading because, in those cases when actual correction is
possible (rather than, say, an emergency data save), you can't
reasonably do it after malloc. You need a malloc replacement:[1]

No you don't. For example, the program may simply announce that
memory is full, therefore it is not accepting more input, and
proceed to process what it has.
 
B

Ben Bacarisse

CBFalconer said:
Ben said:
... snip ...

In your suggested pattern, the name 'attemptcorrection' is rather
misleading because, in those cases when actual correction is
possible (rather than, say, an emergency data save), you can't
reasonably do it after malloc. You need a malloc replacement:[1]

No you don't. For example, the program may simply announce that
memory is full, therefore it is not accepting more input, and
proceed to process what it has.

That is not what I'd call 'attemptcorrection'. But I agree, if you
*don't* want to attempt any significant correction, then your outline
suits the situation perfectly.
 
C

CBFalconer

Ben said:
CBFalconer said:
Ben said:
... snip ...

In your suggested pattern, the name 'attemptcorrection' is rather
misleading because, in those cases when actual correction is
possible (rather than, say, an emergency data save), you can't
reasonably do it after malloc. You need a malloc replacement:[1]

No you don't. For example, the program may simply announce that
memory is full, therefore it is not accepting more input, and
proceed to process what it has.

That is not what I'd call 'attemptcorrection'. But I agree, if
you *don't* want to attempt any significant correction, then your
outline suits the situation perfectly.

That IS a significant correction. It changes the objective of the
program according to resources available. I use it (or the
equivalent) in many situations. You can see one in my hashlib
package.
 
D

David Thompson

Herhor said:

Fine, given appropriate definitions of new and delete, and provided
delete isn't 0, of course. Otherwise, the behaviour is undefined.

Also if new==INT_MIN /* or LONG etc */ && delete==-1
on most (2sC) systems. <G>
- formerly david.thompson1 || achar(64) || worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,839
Latest member
MartinaBur

Latest Threads

Top