Mercurial > hg > GearsTemplate
changeset 5:b8066055e295
fix
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Mar 2015 16:19:17 +0900 |
parents | cd262e34ac1a |
children | 59c1086467f9 |
files | src/allocate.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);