diff options
Diffstat (limited to 'push.c')
| -rw-r--r-- | push.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#include "prv.h" +#include <stdlib.h> + +int push(const struct pos *pos, struct prv *p) +{ + size_t n = p->n + 1; + struct pos *npos = realloc(p->pos, n * sizeof *npos); + + if (!npos) + { + perror("realloc(3)"); + return -1; + } + else if (p->n) + { + struct pos *prev = &npos[p->n - 1]; + + prev->seq = prev->stseq; + prev->step = prev->seq->steps; + p->i++; + } + + npos[p->n++] = *pos; + p->pos = npos; + return 0; +} |
