[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/18] Move need_chars into handletoken.c
From: |
Tim Hentenaar |
Subject: |
[PATCH 05/18] Move need_chars into handletoken.c |
Date: |
Sat, 4 Jul 2015 13:43:19 +0200 |
Signed-off-by: Tim Hentenaar <address@hidden>
---
src/handletoken.c | 22 +++++++++++++++++++++-
src/handletoken.h | 25 +------------------------
src/indent.h | 8 --------
3 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/src/handletoken.c b/src/handletoken.c
index 768e5e0..3baf97f 100644
--- a/src/handletoken.c
+++ b/src/handletoken.c
@@ -76,9 +76,29 @@
RCSTAG_CC ("$GNU$");
/**
- *
+ * Expand a buffer to hold more chars, aligned on a
+ * 1 KB boundary.
*/
+extern void need_chars(buf_ty * bp, size_t needed)
+{
+ size_t current_size = (size_t)(bp->end - bp->ptr);
+
+ if (current_size + needed >= bp->size)
+ {
+ bp->size = ((current_size + needed) & (size_t)~1023);
+ bp->ptr = xrealloc(bp->ptr, bp->size);
+ if (bp->ptr == NULL)
+ {
+ fatal (_("Ran out of memory"), 0);
+ }
+ bp->end = bp->ptr + current_size;
+ }
+}
+
+/**
+ *
+ */
extern void check_code_size(void)
{
if (e_code >= l_code)
diff --git a/src/handletoken.h b/src/handletoken.h
index d76ca2f..cb3949b 100644
--- a/src/handletoken.h
+++ b/src/handletoken.h
@@ -20,28 +20,5 @@ extern void handle_the_token(
BOOLEAN * pbreak_line);
extern void check_code_size(void);
-
-/**
- *
- */
-
-static void INLINE need_chars (
- buf_ty * bp,
- int needed)
-{
- int current_size = (bp->end - bp->ptr);
-
- if ((current_size + needed) >= bp->size)
- {
- bp->size = ROUND_UP (current_size + needed, 1024);
- bp->ptr = xrealloc (bp->ptr, bp->size);
- if (bp->ptr == NULL)
- {
- fatal (_("Ran out of memory"), 0);
- }
-
- bp->end = bp->ptr + current_size;
- }
-}
-
+extern void need_chars(buf_ty * bp, size_t needed);
#endif
diff --git a/src/indent.h b/src/indent.h
index f80b40a..4d8f5e1 100644
--- a/src/indent.h
+++ b/src/indent.h
@@ -66,14 +66,6 @@ RCSTAG_H (indent, "$Id$");
#include "lexi.h"
-/**
- * Round up P to be a multiple of SIZE.
- */
-
-#ifndef ROUND_UP
-#define ROUND_UP(p, size) (((unsigned long) (p) + (size) - 1) & ~((size) - 1))
-#endif
-
/** Values that `indent' can return for exit status.
*
* `total_success' means no errors or warnings were found during a successful
--
2.3.6
- [PATCH 00/18] Various fixes and improvements, Tim Hentenaar, 2015/07/04
- [PATCH 01/18] AM_CFLAGS: Add -ansi -pedantic and some warnings, Tim Hentenaar, 2015/07/04
- [PATCH 02/18] indent.h: Remove redundant extern declaration of else_or_endif, Tim Hentenaar, 2015/07/04
- [PATCH 03/18] globs: Fix malloc() wrapper functions, Tim Hentenaar, 2015/07/04
- [PATCH 04/18] s/free/xfree/g, Tim Hentenaar, 2015/07/04
- [PATCH 05/18] Move need_chars into handletoken.c,
Tim Hentenaar <=
- [PATCH 06/18] args: Compiler warning fixes, Tim Hentenaar, 2015/07/04
- [PATCH 07/18] gperf*.c: Fix compiler warnings, Tim Hentenaar, 2015/07/04
- [PATCH 08/18] texinfo2man: Fix potential buffer overruns and NULL pointer dereferences, Tim Hentenaar, 2015/07/04
- [PATCH 09/18] output.c: Remove dead code, Tim Hentenaar, 2015/07/04
- [PATCH 10/18] output.c: Fix potential NULL pointer dereferences, Tim Hentenaar, 2015/07/04
- [PATCH 11/18] output.c: Remove unused variable 'boolean_operator', Tim Hentenaar, 2015/07/04
- [PATCH 12/18] globs: Fix WARNING and ERROR macros to use char * instead of int *, Tim Hentenaar, 2015/07/04
- [PATCH 13/18] sys.h: Remove unused INLINE macro, Tim Hentenaar, 2015/07/04
- [PATCH 14/18] lexi.c: Remove dead code, Tim Hentenaar, 2015/07/04
- [PATCH 15/18] output: Don't shadow current_column(), Tim Hentenaar, 2015/07/04