bug-indent
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]