S
Sander
1.
I was having a discussion with somebody and I think it's just religious.
We are developing some software and he was looking through my code.
I use if (pointer) to test a pointer for NULL. He says it must be if
(p!=NULL).
The arguments are that it's more readable and that if (p) is not portable.
I said the first is a style issue and that I think if(p) is more readable
and that the second is plain wrong.
So, is he right about the portability issue? is if (p) not strictly correct
C code?
2.
Then I started looking through his code and what I noticed that he very
often does things like this:
char *func(char **out)
{
*out = malloc(100);
return malloc(10);
}
This might also be a style issue, but it's a style where it's very easy to
introduce bugs (and indeed I found a few)
and even more easy to introduce bugs if you don't know the internals of the
function. So, what do you think about this style?
I was having a discussion with somebody and I think it's just religious.
We are developing some software and he was looking through my code.
I use if (pointer) to test a pointer for NULL. He says it must be if
(p!=NULL).
The arguments are that it's more readable and that if (p) is not portable.
I said the first is a style issue and that I think if(p) is more readable
and that the second is plain wrong.
So, is he right about the portability issue? is if (p) not strictly correct
C code?
2.
Then I started looking through his code and what I noticed that he very
often does things like this:
char *func(char **out)
{
*out = malloc(100);
return malloc(10);
}
This might also be a style issue, but it's a style where it's very easy to
introduce bugs (and indeed I found a few)
and even more easy to introduce bugs if you don't know the internals of the
function. So, what do you think about this style?