summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/buf.c
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-03 11:59:30 +0000
committerharti <harti@FreeBSD.org>2004-12-03 11:59:30 +0000
commit41fdfcd45f1625cf137b07e507748affb1adc408 (patch)
treef7d0309ef7ab420ac4ee6ef12a1d9a25a48d71cd /usr.bin/make/buf.c
parentf004ee8cb0cfccb903d8a9c518043b2ce7bde03a (diff)
downloadFreeBSD-src-41fdfcd45f1625cf137b07e507748affb1adc408.zip
FreeBSD-src-41fdfcd45f1625cf137b07e507748affb1adc408.tar.gz
Make sizes to be of type size_t and correct function arguments that
should be Byte (as the numerous casts to Byte in the function calls show).
Diffstat (limited to 'usr.bin/make/buf.c')
-rw-r--r--usr.bin/make/buf.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
index 3d43423..190b2aa 100644
--- a/usr.bin/make/buf.c
+++ b/usr.bin/make/buf.c
@@ -93,7 +93,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
void
-Buf_OvAddByte(Buffer bp, int byte)
+Buf_OvAddByte(Buffer bp, Byte byte)
{
bp->left = 0;
@@ -122,7 +122,7 @@ Buf_OvAddByte(Buffer bp, int byte)
*-----------------------------------------------------------------------
*/
void
-Buf_AddBytes(Buffer bp, int numBytes, const Byte *bytesPtr)
+Buf_AddBytes(Buffer bp, size_t numBytes, const Byte *bytesPtr)
{
BufExpand(bp, numBytes);
@@ -151,7 +151,7 @@ Buf_AddBytes(Buffer bp, int numBytes, const Byte *bytesPtr)
*-----------------------------------------------------------------------
*/
void
-Buf_UngetByte(Buffer bp, int byte)
+Buf_UngetByte(Buffer bp, Byte byte)
{
if (bp->outPtr != bp->buffer) {
@@ -171,7 +171,7 @@ Buf_UngetByte(Buffer bp, int byte)
* usually push back many bytes when they're doing it a byte at
* a time...
*/
- int numBytes = bp->inPtr - bp->outPtr;
+ size_t numBytes = bp->inPtr - bp->outPtr;
Byte *newBuf;
newBuf = emalloc(bp->size + BUF_UNGET_INC);
@@ -201,18 +201,18 @@ Buf_UngetByte(Buffer bp, int byte)
*-----------------------------------------------------------------------
*/
void
-Buf_UngetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
+Buf_UngetBytes(Buffer bp, size_t numBytes, Byte *bytesPtr)
{
- if (bp->outPtr - bp->buffer >= numBytes) {
+ if ((size_t)(bp->outPtr - bp->buffer) >= numBytes) {
bp->outPtr -= numBytes;
memcpy(bp->outPtr, bytesPtr, numBytes);
} else if (bp->outPtr == bp->inPtr) {
Buf_AddBytes(bp, numBytes, bytesPtr);
} else {
- int curNumBytes = bp->inPtr - bp->outPtr;
+ size_t curNumBytes = bp->inPtr - bp->outPtr;
Byte *newBuf;
- int newBytes = max(numBytes, BUF_UNGET_INC);
+ size_t newBytes = max(numBytes, BUF_UNGET_INC);
newBuf = emalloc(bp->size + newBytes);
memcpy(newBuf + newBytes, bp->outPtr, curNumBytes + 1);
@@ -274,10 +274,10 @@ Buf_GetByte(Buffer bp)
*-----------------------------------------------------------------------
*/
int
-Buf_GetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
+Buf_GetBytes(Buffer bp, size_t numBytes, Byte *bytesPtr)
{
- if (bp->inPtr - bp->outPtr < numBytes)
+ if ((size_t)(bp->inPtr - bp->outPtr) < numBytes)
numBytes = bp->inPtr - bp->outPtr;
memcpy(bytesPtr, bp->outPtr, numBytes);
@@ -305,7 +305,7 @@ Buf_GetBytes(Buffer bp, int numBytes, Byte *bytesPtr)
*-----------------------------------------------------------------------
*/
Byte *
-Buf_GetAll(Buffer bp, int *numBytesPtr)
+Buf_GetAll(Buffer bp, size_t *numBytesPtr)
{
if (numBytesPtr != NULL)
@@ -328,10 +328,10 @@ Buf_GetAll(Buffer bp, int *numBytesPtr)
*-----------------------------------------------------------------------
*/
void
-Buf_Discard(Buffer bp, int numBytes)
+Buf_Discard(Buffer bp, size_t numBytes)
{
- if (bp->inPtr - bp->outPtr <= numBytes) {
+ if ((size_t)(bp->inPtr - bp->outPtr) <= numBytes) {
bp->inPtr = bp->outPtr = bp->buffer;
bp->left = bp->size;
*bp->inPtr = 0;
@@ -353,7 +353,7 @@ Buf_Discard(Buffer bp, int numBytes)
*
*-----------------------------------------------------------------------
*/
-int
+size_t
Buf_Size(Buffer buf)
{
@@ -376,7 +376,7 @@ Buf_Size(Buffer buf)
*-----------------------------------------------------------------------
*/
Buffer
-Buf_Init(int size)
+Buf_Init(size_t size)
{
Buffer bp; /* New Buffer */
@@ -430,7 +430,7 @@ Buf_Destroy(Buffer buf, Boolean freeData)
*-----------------------------------------------------------------------
*/
void
-Buf_ReplaceLastByte(Buffer buf, int byte)
+Buf_ReplaceLastByte(Buffer buf, Byte byte)
{
if (buf->inPtr == buf->outPtr)
Buf_AddByte(buf, byte);
OpenPOWER on IntegriCloud