More printf and unnecessary header removal, improve preprocessed blank lines
authorNick Downing <nick@ndcode.org>
Sat, 18 May 2019 01:23:12 +0000 (11:23 +1000)
committerNick Downing <nick@ndcode.org>
Sat, 18 May 2019 01:23:12 +0000 (11:23 +1000)
blank.py
core.c
process.c
swap.c

index 823ba15..f4f1e9f 100755 (executable)
--- a/blank.py
+++ b/blank.py
@@ -5,7 +5,7 @@ import sys
 opens = set(['(', '{', '['])
 closes = set([')', '}', ']'])
 
-before = ''
+before = None
 blank = False
 for i in sys.stdin:
   i = i.rstrip()
@@ -13,7 +13,7 @@ for i in sys.stdin:
     blank = True
   else:
     after = i.lstrip()
-    if blank and len(before) and before[-1:] not in opens and after[:1] not in closes:
+    if blank and before is not None and before[-1:] not in opens and after[:1] not in closes:
       sys.stdout.write('\n')
     sys.stdout.write(i + '\n')
     j = i.find('//')
diff --git a/core.c b/core.c
index 3b4f3e0..4285051 100644 (file)
--- a/core.c
+++ b/core.c
@@ -1,8 +1,10 @@
 #include <assert.h>
 #include <stddef.h>
-#include <stdio.h>
+//#include <stdio.h>
 #include <stdlib.h>
+#ifndef NDEBUG
 #include <string.h>
+#endif
 #include "core.h"
 #include "process.h"
 #include "rassert.h"
@@ -132,7 +134,9 @@ void core_init(int n_blocks)
 #ifdef INDIRECT_CORE
   core_table_mem = malloc(table_size * sizeof(int));
   rassert(core_table_mem);
+#ifndef NDEBUG
   memset(core_table_mem, 0x55, table_size * sizeof(int));
+#endif
 
   block_pool_init(&core_block_pool, n_blocks);
 #endif
index 7befffc..5fc8baf 100644 (file)
--- a/process.c
+++ b/process.c
@@ -1,9 +1,6 @@
 #include <assert.h>
 #include <stdio.h> // temporary
 #include <stdlib.h>
-#ifndef NDEBUG
-#include <string.h>
-#endif
 #include "core.h"
 #include "process.h"
 #include "rassert.h"
diff --git a/swap.c b/swap.c
index 58e5979..b3226cc 100644 (file)
--- a/swap.c
+++ b/swap.c
@@ -1,8 +1,10 @@
 #include <assert.h>
 #include <stddef.h>
-#include <stdio.h>
+//#include <stdio.h>
 #include <stdlib.h>
+#ifndef NDEBUG
 #include <string.h>
+#endif
 #include "swap.h"
 #include "process.h"
 #include "rassert.h"
@@ -28,13 +30,13 @@ static void swap_move(struct pool_item *item, int new_base) {
 
   base = item->base;
   blocks = item->limit - base;
-  printf(
-    "swap_move [%d,%d) to [%d,%d)\n",
-    base,
-    base + blocks,
-    new_base,
-    new_base + blocks
-  );
+  //printf(
+  //  "swap_move [%d,%d) to [%d,%d)\n",
+  //  base,
+  //  base + blocks,
+  //  new_base,
+  //  new_base + blocks
+  //);
   assert(new_base <= base || new_base >= base + blocks);
 #ifdef INDIRECT_SWAP
   for (i = 0; i < blocks; ++i) {
@@ -69,13 +71,13 @@ static void swap_move_up(struct pool_item *item, int new_limit) {
 
   limit = item->limit;
   blocks = limit - item->base;
-  printf(
-    "swap_move_up [%d,%d) to [%d,%d)\n",
-    limit - blocks,
-    limit,
-    new_limit - blocks,
-    new_limit
-  );
+  //printf(
+  //  "swap_move_up [%d,%d) to [%d,%d)\n",
+  //  limit - blocks,
+  //  limit,
+  //  new_limit - blocks,
+  //  new_limit
+  //);
   assert(new_limit >= limit || new_limit <= limit - blocks);
 #ifdef INDIRECT_SWAP
   blocks = -blocks;
@@ -132,7 +134,9 @@ void swap_init(int n_blocks)
 #ifdef INDIRECT_SWAP
   swap_table_mem = malloc(table_size * sizeof(int));
   rassert(swap_table_mem);
+#ifndef NDEBUG
   memset(swap_table_mem, 0x55, table_size * sizeof(int));
+#endif
 
   block_pool_init(&swap_block_pool, n_blocks);
 #endif