mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-19 14:54:24 +00:00
None of the users of Buf_Discard used it to get rid of only a part of
the buffer. So replace Buf_Discard by Buf_Clear which just gets rid of the entire contents. Submitted by: Max Okumoto <okumoto@ucsd.edu>
This commit is contained in:
parent
2e047e2eb8
commit
b8900c134b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141275
|
@ -163,31 +163,6 @@ Buf_GetAll(Buffer *bp, size_t *numBytesPtr)
|
|||
return (bp->outPtr);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Discard --
|
||||
* Throw away bytes in a buffer.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* The bytes are discarded.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_Discard(Buffer *bp, size_t numBytes)
|
||||
{
|
||||
|
||||
if ((size_t)(bp->inPtr - bp->outPtr) <= numBytes) {
|
||||
bp->inPtr = bp->outPtr = bp->buffer;
|
||||
bp->left = bp->size;
|
||||
*bp->inPtr = 0;
|
||||
} else
|
||||
bp->outPtr += numBytes;
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Size --
|
||||
|
@ -286,3 +261,13 @@ Buf_ReplaceLastByte(Buffer *buf, Byte byte)
|
|||
else
|
||||
*(buf->inPtr - 1) = byte;
|
||||
}
|
||||
|
||||
void
|
||||
Buf_Clear(Buffer *bp)
|
||||
{
|
||||
bp->inPtr = bp->buffer;
|
||||
bp->outPtr = bp->buffer;
|
||||
bp->left = bp->size;
|
||||
bp->inPtr[0] = '\0';
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ typedef struct Buffer {
|
|||
void Buf_OvAddByte(Buffer *, Byte);
|
||||
void Buf_AddBytes(Buffer *, size_t, const Byte *);
|
||||
Byte *Buf_GetAll(Buffer *, size_t *);
|
||||
void Buf_Discard(Buffer *, size_t);
|
||||
void Buf_Clear(Buffer *);
|
||||
size_t Buf_Size(Buffer *);
|
||||
Buffer *Buf_Init(size_t);
|
||||
void Buf_Destroy(Buffer *, Boolean);
|
||||
|
|
|
@ -2018,7 +2018,7 @@ ParseSkipLine(int skip, int keep_newline)
|
|||
buf = Buf_Init(MAKE_BSIZE);
|
||||
|
||||
do {
|
||||
Buf_Discard(buf, lineLength);
|
||||
Buf_Clear(buf);
|
||||
lastc = '\0';
|
||||
|
||||
while (((c = ParseReadc()) != '\n' || lastc == '\\')
|
||||
|
|
|
@ -436,7 +436,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt)
|
|||
if (v == NULL) {
|
||||
VarAdd(n, val, ctxt);
|
||||
} else {
|
||||
Buf_Discard(v->val, Buf_Size(v->val));
|
||||
Buf_Clear(v->val);
|
||||
Buf_AddBytes(v->val, strlen(val), (const Byte *)val);
|
||||
|
||||
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, val));
|
||||
|
|
Loading…
Reference in a new issue