Always cast malloc

E

E. Robert Tisdale

Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of


double* x = malloc(n*sizeof(*x));
 
A

Artie Gold

E. Robert Tisdale said:
Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of


double* x = malloc(n*sizeof(*x));

Always refrigerate tomatoes. Makes just about as much sense.

--aG
 
J

Jalapeno

"E. Robert Tisdale said:
Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of


double* x = malloc(n*sizeof(*x));

This is secret code. I'm telling Ashcroft on you.
 
M

Mike Wahler

E. Robert Tisdale said:
Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of


double* x = malloc(n*sizeof(*x));\

Slow day today, Robert?

-Mike
 
K

Keith Thompson

E. Robert Tisdale said:
Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of

double* x = malloc(n*sizeof(*x));

Is this a deliberate troll? If so, please stop wasting our time and
confusing the newbies. If you really have a point, please explain it.

A quick response just in case you're serious about this:

You're wrong.
 
E

E. Robert Tisdale

Mike said:
Slow day today, Robert?

I dug this up out of another thread: why still use C?
Sidney Cadot and Mark McIntyre are having a slow day as well.
 
M

Mike Wahler

E. Robert Tisdale said:
I dug this up out of another thread: why still use C?

And presented it here without context.
Sidney Cadot and Mark McIntyre are having a slow day as well.

So what's your motivation for posting a couple lines from
another thread without context?

I find this quite ironic from one who is very quick
to cry 'troll' around here.

-Mike
 
R

Richard Heathfield

E. Robert Tisdale said:
Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of


double* x = malloc(n*sizeof(*x));


The latter is clearly superior, for reasons which have been presented ad
nauseam in this newsgroup for years. That Tisdale recommends the former,
then, comes as no surprise. His advice may safely be ignored.
 
I

Irrwahn Grausewitz

Always write:

double *x = malloc(n * sizeof *x);

instead of


double* x = malloc(n*sizeof(*x));
 
D

Dan Pop

In said:
Always write:

double* x = (double*)malloc(n*sizeof(double));

instead of


double* x = malloc(n*sizeof(*x));

_____________________
/| /| | |
||__|| | Please do not |
/ O O\__ | feed the |
/ \ | Trolls |
/ \ \|_____________________|
/ _ \ \ ||
/ |\____\ \ ||
/ | | | |\____/ ||
/ \|_|_|/ | _||
/ / \ |____| ||
/ | | | --|
| | | |____ --|
* _ | |_|_|_| | \-/
*-- _--\ _ \ | ||
/ _ \\ | / `'
* / \_ /- | | |
* ___ c_c_c_C/ \C_c_c_c____________

Dan
 
T

The Clap

In said:
_____________________
/| /| | |
||__|| | Please do not |
/ O O\__ | feed the |
/ \ | Trolls |
/ \ \|_____________________|
/ _ \ \ ||
/ |\____\ \ ||
/ | | | |\____/ ||
/ \|_|_|/ | _||
/ / \ |____| ||
/ | | | --|
| | | |____ --|
* _ | |_|_|_| | \-/
*-- _--\ _ \ | ||
/ _ \\ | / `'
* / \_ /- | | |
* ___ c_c_c_C/ \C_c_c_c____________

Dan

http://goatse.cx/

* g o a t s e x * g o a t s e x * g o a t s e x *
g g
o / \ \ / \ o
a| | \ | | a
t| `. | | : t
s` | | \| | s
e \ | / / \\\ --__ \\ : e
x \ \/ _--~~ ~--__| \ | x
* \ \_-~ ~-_\ | *
g \_ \ _.--------.______\| | g
o \ \______// _ ___ _ (_(__> \ | o
a \ . C ___) ______ (_(____> | / a
t /\ | C ____)/ Dan \ (_____> |_/ t
s / /\| C_____) Pop | (___> / \ s
e | ( _C_____)\______/ // _/ / \ e
x | \ |__ \\_________// (__/ | x
* | \ \____) `---- --' | *
g | \_ ___\ /_ _/ | g
o | / | | \ | o
a | | / \ \ | a
t | / / | | \ |t
s | / / \__/\___/ | |s
e | / / | | | |e
x | | | | | |x
* g o a t s e x * g o a t s e x * g o a t e x *

http://goatse.cx/
 
C

CBFalconer

Richard said:
.... snip ...

The latter is clearly superior, for reasons which have been presented ad
nauseam in this newsgroup for years. That Tisdale recommends the former,
then, comes as no surprise. His advice may safely be ignored.

I think that is a syntax error. It should be "His advice may not
be taken in safety". A Karnaugh map of the available actions may
make it clearer.
 
S

Sidney Cadot

Hi Mark,
Slow day today, Robert?

How about we put an end to our mutual barrage of repetitive statements?
Hells bells, I'll even leave the final round to you. I'm sure we can
find another topic later on to slug it out :)

Best regards, Sidney
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top