[esnacc-dev] [PATCH 5/7] exp-buf: Simplify put byte
Aaron Conole
aconole at bytheb.org
Tue Dec 20 17:14:12 UTC 2016
The put byte code was awful. This is a quick 'n dirty cleanup - hopefully
the full buffer system here can get a cleanup.
Signed-off-by: Aaron Conole <aconole at bytheb.org>
---
c-lib/src/exp-buf.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/c-lib/src/exp-buf.c b/c-lib/src/exp-buf.c
index 3bac68f..2062087 100644
--- a/c-lib/src/exp-buf.c
+++ b/c-lib/src/exp-buf.c
@@ -943,38 +943,29 @@ ExpBufPutByteRvs PARAMS ((b, byte),
if ((*b)->writeError)
return;
- *(--(*b)->dataStart) = byte;
-
/*
* check if buffer is full and alloc new one if nec
* and insert it before this one since writing backwards
*/
- if (ExpBufFull (*b))
- {
- if ((*b)->prev == NULL)
- {
+ if (ExpBufFull (*b)) {
+ if ((*b)->prev == NULL) {
/*
* no prev buf so alloc & insert
* new buf as head of buffer list
*/
new = ExpBufAllocBufAndData();
- if (new == NULL)
- {
+ if (new == NULL) {
(*b)->writeError = 1;
return;
}
-
new->next = *b;
(*b)->prev = new;
- *b = new;
}
- else
- {
- (*b) = (*b)->prev;
- ExpBufResetInWriteRvsMode (*b);
- }
-
+ (*b) = (*b)->prev;
+ ExpBufResetInWriteRvsMode (*b);
}
+
+ *(--(*b)->dataStart) = byte;
} /* ExpBufPutByteRvs */
--
2.7.4
More information about the dev
mailing list