summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/chan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/chan.c')
-rw-r--r--src/pkg/runtime/chan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c
index bea1a34f8..ef27144ef 100644
--- a/src/pkg/runtime/chan.c
+++ b/src/pkg/runtime/chan.c
@@ -586,6 +586,10 @@ newselect(int32 size, Select **selp)
if(size > 1)
n = size-1;
+ // allocate all the memory we need in a single allocation
+ // start with Select with size cases
+ // then lockorder with size entries
+ // then pollorder with size entries
sel = runtimeĀ·mal(sizeof(*sel) +
n*sizeof(sel->scase[0]) +
size*sizeof(sel->lockorder[0]) +
@@ -593,8 +597,8 @@ newselect(int32 size, Select **selp)
sel->tcase = size;
sel->ncase = 0;
- sel->pollorder = (void*)(sel->scase + size);
- sel->lockorder = (void*)(sel->pollorder + size);
+ sel->lockorder = (void*)(sel->scase + size);
+ sel->pollorder = (void*)(sel->lockorder + size);
*selp = sel;
if(debug)