mirror of https://github.com/omar-polo/gmid.git
sync recallocarary.c
original commit from claudio@: Type-cast getpagesize() from int to size_t for the comparison with d. getpagesize() will only return positive numbers (there is no negative page size system) and it can not fail. Should fix some compiler warnings seen in -portable projects. OK otto@
This commit is contained in:
parent
e5d82d9472
commit
c7949fd545
|
@ -1,3 +1,4 @@
|
|||
/* $OpenBSD: recallocarray.c,v 1.2 2021/03/18 11:16:58 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net>
|
||||
*
|
||||
|
@ -66,7 +67,7 @@ recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size)
|
|||
if (newsize <= oldsize) {
|
||||
size_t d = oldsize - newsize;
|
||||
|
||||
if (d < oldsize / 2 && d < getpagesize()) {
|
||||
if (d < oldsize / 2 && d < (size_t)getpagesize()) {
|
||||
memset((char *)ptr + newsize, 0, d);
|
||||
return ptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue