don't try to create an image for a chunked heap

This commit is contained in:
Alex Shinn 2016-01-26 23:36:55 +09:00
parent 3e28bdef8b
commit 9a9202716c

6
main.c
View file

@ -170,12 +170,16 @@ static int sexp_save_image (sexp ctx, const char* path) {
sexp_heap heap; sexp_heap heap;
FILE* file; FILE* file;
struct sexp_image_header_t header; struct sexp_image_header_t header;
heap = sexp_context_heap(ctx);
if (heap->next) {
fprintf(stderr, "can't save image for a chunked heap, try a larger initial heap with -h\n");
return 0;
}
file = fopen(path, "w"); file = fopen(path, "w");
if (!file) { if (!file) {
fprintf(stderr, "couldn't open image file for writing: %s\n", path); fprintf(stderr, "couldn't open image file for writing: %s\n", path);
return 0; return 0;
} }
heap = sexp_context_heap(ctx);
memcpy(&header.magic, SEXP_IMAGE_MAGIC, sizeof(header.magic)); memcpy(&header.magic, SEXP_IMAGE_MAGIC, sizeof(header.magic));
memcpy(&header.abi, SEXP_ABI_IDENTIFIER, sizeof(header.abi)); memcpy(&header.abi, SEXP_ABI_IDENTIFIER, sizeof(header.abi));
header.major = SEXP_IMAGE_MAJOR_VERSION; header.major = SEXP_IMAGE_MAJOR_VERSION;