Mercurial > repos > tabletprog
comparison cbackend.js @ 61:a6addd8c6bd4
Fix array resizing to use newsize * sizeof(object *) rather than just newsize
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 14 Jul 2012 04:18:46 -0700 |
parents | ef3b34c2c0a4 |
children | 25b697c91629 |
comparison
equal
deleted
inserted
replaced
60:ef3b34c2c0a4 | 61:a6addd8c6bd4 |
---|---|
476 array.addMessage('append', { | 476 array.addMessage('append', { |
477 vars: {tmp: 'object **'}, | 477 vars: {tmp: 'object **'}, |
478 lines: [ | 478 lines: [ |
479 'if (self->storage == self->size) {', | 479 'if (self->storage == self->size) {', |
480 ' self->storage *= 2;', | 480 ' self->storage *= 2;', |
481 ' tmp = realloc(self->data, self->storage);', | 481 ' tmp = realloc(self->data, self->storage * sizeof(object *));', |
482 ' if (!tmp) {', | 482 ' if (!tmp) {', |
483 ' fputs("Failed to increase array size\\n", stderr);', | 483 ' fputs("Failed to increase array size\\n", stderr);', |
484 ' exit(1);', | 484 ' exit(1);', |
485 ' }', | 485 ' }', |
486 ' self->data = tmp;', | 486 ' self->data = tmp;', |