annotate src/allocate/allocate.c @ 8:714d0ce1efd7

change configuring directory
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Wed, 01 Apr 2015 22:56:51 +0900
parents src/allocate.c@ad48a076a8e5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
cd262e34ac1a allocate example
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
1 #include <stdlib.h>
cd262e34ac1a allocate example
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
2
cd262e34ac1a allocate example
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
3 #include "allocate.h"
cd262e34ac1a allocate example
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
4
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
5 __code allocate(Context* context, int size, int num, __code (*next)()) {
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
6 goto meta_allocate(context, size, num, next);
4
cd262e34ac1a allocate example
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
7 }
cd262e34ac1a allocate example
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
8
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
9 __code meta_allocate(Context* context, int size, int num, __code (*next)()) {
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
10 context->next = next;
7
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
11 void* ds = context->ds;
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
12 context->ds += size*num;
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
13 ((mdata*)context->mds)->ds = ds;
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
14 ((mdata*)context->mds)->size = size;
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
15 context->mds = (mdata*)context->mds+1;
8
714d0ce1efd7 change configuring directory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
16 goto context->next(context, (data1*)ds, 0);
7
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
17 }