1. Mort Yao
  2. icfp-2012

Commits

Mort Yao  committed 43daea1

fixed getCells(): array subscript out-of-range

  • Participants
  • Parent commits d3651eb
  • Branches master

Comments (0)

Files changed (2)

File src/datatypes/cell.c

View file
  • Ignore whitespace
 #include <stdlib.h>
+#include <string.h>
 
 #include "cell.h"
 #include "matrix.h"
     c->elem = NULL;
     
     for (int i = 0; i < m.height; i++)
-        for (int j = 0; j < m.width; j++)
+        for (int j = 0; j < m.width && j < strlen(m.elem[i]); j++)
             if (m.elem[i][j] == ch) {
                 Cell *p = realloc(c->elem, ++size * sizeof(Cell));
                 if (p == NULL)

File src/main.c

View file
  • Ignore whitespace
     score = core_bb(solution, env, map, stat, 140);
     
     printf("%s\n", solution);
-    //printf("%d\n", score); // for testing
+    printf("%d\n", score); // for testing
     
     free(solution);