mirror of https://github.com/xzeldon/htop.git
Revert 5c593fae42
(xCalloc)
calloc() allows 'nmemb' or 'size' to be zero, in which case NULL may be returned. Letting htop die because of either argument being zero doesn't make sense. As a side note: As size_t is unsigned, compiler should be able to optimize conditional (nmemb > 0 && size > 0) to (nmemb && size). This theorically shouldn't increase code size too much.
This commit is contained in:
parent
3283c6d23c
commit
7d3f67e822
2
XAlloc.c
2
XAlloc.c
|
@ -29,7 +29,7 @@ void* xMalloc(size_t size) {
|
||||||
|
|
||||||
void* xCalloc(size_t nmemb, size_t size) {
|
void* xCalloc(size_t nmemb, size_t size) {
|
||||||
void* data = calloc(nmemb, size);
|
void* data = calloc(nmemb, size);
|
||||||
if (!data) {
|
if (!data && nmemb > 0 && size > 0) {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Reference in New Issue