summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/buf.c
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-01 10:29:20 +0000
committerharti <harti@FreeBSD.org>2004-12-01 10:29:20 +0000
commitcf2c3cae344e2c0fd2316b579a8e3698105b58d1 (patch)
treed8d62254033c89332ede3fdf3277528114f7a6b5 /usr.bin/make/buf.c
parenta50f0bcbfd79a523bed7c5e00964a797edad9ff7 (diff)
downloadFreeBSD-src-cf2c3cae344e2c0fd2316b579a8e3698105b58d1.zip
FreeBSD-src-cf2c3cae344e2c0fd2316b579a8e3698105b58d1.tar.gz
Style: remove a lot of unnecessary casts, add some and spell the null
pointer constant as NULL. Checked by: diff -r on the object files before and after
Diffstat (limited to 'usr.bin/make/buf.c')
-rw-r--r--usr.bin/make/buf.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
index c344738..84b62fd 100644
--- a/usr.bin/make/buf.c
+++ b/usr.bin/make/buf.c
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
#define BufExpand(bp,nb) \
if (bp->left < (nb)+1) {\
int newSize = (bp)->size + max((nb) + 1, BUF_ADD_INC); \
- Byte *newBuf = (Byte *)erealloc((bp)->buffer, newSize); \
+ Byte *newBuf = erealloc((bp)->buffer, newSize); \
\
(bp)->inPtr = newBuf + ((bp)->inPtr - (bp)->buffer); \
(bp)->outPtr = newBuf + ((bp)->outPtr - (bp)->buffer);\
@@ -94,6 +94,7 @@ __FBSDID("$FreeBSD$");
void
Buf_OvAddByte(Buffer bp, int byte)
{
+
bp->left = 0;
BufExpand(bp, 1);
@@ -170,12 +171,11 @@ Buf_UngetByte(Buffer bp, int byte)
int numBytes = bp->inPtr - bp->outPtr;
Byte *newBuf;
- newBuf = (Byte *)emalloc(bp->size + BUF_UNGET_INC);
- memcpy((char *)(newBuf+BUF_UNGET_INC), (char *)bp->outPtr,
- numBytes + 1);
+ newBuf = emalloc(bp->size + BUF_UNGET_INC);
+ memcpy(newBuf + BUF_UNGET_INC, bp->outPtr, numBytes + 1);
bp->outPtr = newBuf + BUF_UNGET_INC;
bp->inPtr = bp->outPtr + numBytes;
- free((char *)bp->buffer);
+ free(bp->buffer);
bp->buffer = newBuf;
bp->size += BUF_UNGET_INC;
bp->left = bp->size - (bp->inPtr - bp->buffer);
@@ -211,16 +211,16 @@ Buf_UngetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
Byte *newBuf;
int newBytes = max(numBytes,BUF_UNGET_INC);
- newBuf = (Byte *)emalloc (bp->size + newBytes);
- memcpy((char *)(newBuf+newBytes), (char *)bp->outPtr, curNumBytes + 1);
+ newBuf = emalloc(bp->size + newBytes);
+ memcpy(newBuf + newBytes, bp->outPtr, curNumBytes + 1);
bp->outPtr = newBuf + newBytes;
bp->inPtr = bp->outPtr + curNumBytes;
- free((char *)bp->buffer);
+ free(bp->buffer);
bp->buffer = newBuf;
bp->size += newBytes;
bp->left = bp->size - (bp->inPtr - bp->buffer);
bp->outPtr -= numBytes;
- memcpy((char *)bp->outPtr, (char *)bytesPtr, numBytes);
+ memcpy(bp->outPtr, bytesPtr, numBytes);
}
}
@@ -306,7 +306,7 @@ Byte *
Buf_GetAll(Buffer bp, int *numBytesPtr)
{
- if (numBytesPtr != (int *)NULL) {
+ if (numBytesPtr != NULL) {
*numBytesPtr = bp->inPtr - bp->outPtr;
}
@@ -356,6 +356,7 @@ Buf_Discard(Buffer bp, int numBytes)
int
Buf_Size(Buffer buf)
{
+
return (buf->inPtr - buf->outPtr);
}
@@ -379,13 +380,13 @@ Buf_Init(int size)
{
Buffer bp; /* New Buffer */
- bp = (Buffer)emalloc(sizeof(*bp));
+ bp = emalloc(sizeof(*bp));
if (size <= 0) {
size = BUF_DEF_SIZE;
}
bp->left = bp->size = size;
- bp->buffer = (Byte *)emalloc(size);
+ bp->buffer = emalloc(size);
bp->inPtr = bp->outPtr = bp->buffer;
*bp->inPtr = 0;
@@ -410,9 +411,9 @@ Buf_Destroy(Buffer buf, Boolean freeData)
{
if (freeData) {
- free((char *)buf->buffer);
+ free(buf->buffer);
}
- free((char *)buf);
+ free(buf);
}
/*-
OpenPOWER on IntegriCloud