summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getcap.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-09-16 04:17:47 +0000
committerimp <imp@FreeBSD.org>1998-09-16 04:17:47 +0000
commitbfe73fd683053201c326f9ff2c8e5e0f69cc7fe7 (patch)
treeb17d45198953bfbbad4bfd632dfdf1a37b7159d2 /lib/libc/gen/getcap.c
parent68a8c771724d4fc671cac3ce95f78d4fb1874cfe (diff)
downloadFreeBSD-src-bfe73fd683053201c326f9ff2c8e5e0f69cc7fe7.zip
FreeBSD-src-bfe73fd683053201c326f9ff2c8e5e0f69cc7fe7.tar.gz
Replace memory leaking instances of realloc with non-leaking reallocf.
In some cases replace if (a == null) a = malloc(x); else a = realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is guaranteed to be the same thing. I've been running these on my system here w/o ill effects for some time. However, the CTM-express is at part 6 of 34 for the CAM changes, so I've not been able to do a build world with the CAM in the tree with these changes. Shouldn't impact anything, but...
Diffstat (limited to 'lib/libc/gen/getcap.c')
-rw-r--r--lib/libc/gen/getcap.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index 0295984..aaee0dd 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -344,7 +344,7 @@ getent(cap, len, db_array, fd, name, depth, nfield)
pos = rp - record;
newsize = r_end - record + BFRAG;
- record = realloc(record, newsize);
+ record = reallocf(record, newsize);
if (record == NULL) {
errno = ENOMEM;
if (myfd)
@@ -484,7 +484,7 @@ tc_exp: {
newsize = r_end - record + diff + BFRAG;
tcpos = tcstart - record;
tcposend = tcend - record;
- record = realloc(record, newsize);
+ record = reallocf(record, newsize);
if (record == NULL) {
errno = ENOMEM;
if (myfd)
@@ -524,7 +524,7 @@ tc_exp: {
*len = rp - record - 1; /* don't count NUL */
if (r_end > rp)
if ((record =
- realloc(record, (size_t)(rp - record))) == NULL) {
+ reallocf(record, (size_t)(rp - record))) == NULL) {
errno = ENOMEM;
return (-2);
}
@@ -867,7 +867,7 @@ cgetstr(buf, cap, str)
if (m_room == 0) {
size_t size = mp - mem;
- if ((mem = realloc(mem, size + SFRAG)) == NULL)
+ if ((mem = reallocf(mem, size + SFRAG)) == NULL)
return (-2);
m_room = SFRAG;
mp = mem + size;
@@ -881,7 +881,7 @@ cgetstr(buf, cap, str)
* Give back any extra memory and return value and success.
*/
if (m_room != 0)
- if ((mem = realloc(mem, (size_t)(mp - mem))) == NULL)
+ if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL)
return (-2);
*str = mem;
return (len);
@@ -940,7 +940,7 @@ cgetustr(buf, cap, str)
if (m_room == 0) {
size_t size = mp - mem;
- if ((mem = realloc(mem, size + SFRAG)) == NULL)
+ if ((mem = reallocf(mem, size + SFRAG)) == NULL)
return (-2);
m_room = SFRAG;
mp = mem + size;
@@ -954,7 +954,7 @@ cgetustr(buf, cap, str)
* Give back any extra memory and return value and success.
*/
if (m_room != 0)
- if ((mem = realloc(mem, (size_t)(mp - mem))) == NULL)
+ if ((mem = reallocf(mem, (size_t)(mp - mem))) == NULL)
return (-2);
*str = mem;
return (len);
OpenPOWER on IntegriCloud