Anonymous user
Sokoban/C: Difference between revisions
m
replace asserts
(various bugs) |
m (replace asserts) |
||
Line 5:
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#define ensure(x) { if (!(x)) printf("\nabort: line %d\n", __LINE__); }
int w, h, n_boxes;
Line 41 ⟶ 42:
if (!block_head) {
block_size *= 2;
state_t *p
ensure(p = malloc(block_size * state_size));
alloced += block_size - 1;
p->next = block_root;
block_root = p;
Line 92 ⟶ 93:
{
w = x, h = y;
n_boxes = 0;
Line 181 ⟶ 182:
fill_limit *= 4;
}
buckets = realloc(buckets, sizeof(state_t*) * hash_size);▼
// rehash
▲ ensure(buckets = realloc(buckets, sizeof(state_t*) * hash_size));
memset(buckets + old_size, 0, sizeof(state_t*) * (hash_size - old_size));
Line 236 ⟶ 235:
}
inline bool success(const state_t *s)
{
for (int i = 1; i <= n_boxes; i++)
|