# HG changeset patch # User Shohei KOKUBO # Date 1426663157 -32400 # Node ID b8066055e295a897ab0417b8b7ea6d53e412bb91 # Parent cd262e34ac1a715011a5b7bfaf4a583933f37268 fix diff -r cd262e34ac1a -r b8066055e295 src/allocate.c --- a/src/allocate.c Wed Mar 18 12:41:39 2015 +0900 +++ b/src/allocate.c Wed Mar 18 16:19:17 2015 +0900 @@ -8,6 +8,8 @@ #define _CbC_environment __environment #endif +#define SIZE 1024 + typedef struct DataSegment1 { int i; // 4 byte char c; // 1 byte @@ -39,7 +41,7 @@ } __code meta_code1(contextptr context) { - goto allocate(context, 10); + goto allocate(context, SIZE); } __code allocate(contextptr context, int size) { @@ -58,15 +60,18 @@ __code exit_code(contextptr context, dsptr in, int i) { in[i].i = i; printf("%d\n", in[i].i); - if (i == 10) + if (i == SIZE) { + free(context->ds_heap); + free(context->mds_heap); goto exit(0); + } goto exit_code(context, in, ++i); } int main() { contextptr context = (contextptr)malloc(sizeof(contextptr)); - context->ds_heap = (dsptr)malloc(sizeof(ds)*1024); - context->mds_heap = (mdsptr)malloc(sizeof(mds)*1024); + context->ds_heap = (dsptr)malloc(1024); + context->mds_heap = (mdsptr)malloc(1024); context->ds = context->ds_heap; context->mds = context->mds_heap; goto start_code(context);