home · contact · privacy
Eliminated some potential problems for alternative game map sizes.
[plomrogue] / src / server / io.c
index 10fcd90f3dca2da736f13b1fd2a9e21da93d9efc..2507d3b1e3e3a0faee7842261e1f572e8927fedc 100644 (file)
@@ -4,8 +4,8 @@
 #include <errno.h> /* global errno */
 #include <fcntl.h> /* open(), O_RDONLY, O_NONBLOCK */
 #include <limits.h> /* PIPE_BUF */
-#include <stddef.h> /* size_t */
-#include <stdint.h> /* uint8_t, uint16_t, uint32_t */
+#include <stddef.h> /* size_t, NULL */
+#include <stdint.h> /* uint8_t, uint32_t */
 #include <stdio.h> /* define FILE, sprintf() */
 #include <stdlib.h> /* free() */
 #include <string.h> /* strlen(), memset(), memcpy() */
@@ -66,8 +66,8 @@ static char * get_message_from_queue()
     world.queue_size = world.queue_size - cutout_len;
     if (0 == world.queue_size)
     {
-        free(world.queue);
-        world.queue = NULL;
+        free(world.queue);  /* NULL so read_fifo_into_queue() may free() this */
+        world.queue = NULL; /* every time, even when it's un-allocated first. */
     }
     else
     {
@@ -203,7 +203,7 @@ static void write_map(FILE * file)
             }
         }
     }
-    uint16_t x, y;
+    uint8_t x, y;
     for (y = 0; y < world.map.size.y; y++)
     {
         for (x = 0; x < world.map.size.x; x++)