From 0d7eeab134669dbe801625bc75fb8f7a97cd0200 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 22 Jan 2012 19:56:17 +0100 Subject: [PATCH] Get rid of alloca() usage - non-portable Pointed out by linfk. --- board.c | 1 - distributed/distributed.c | 5 ++--- uct/uct.c | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/board.c b/board.c index 1a06d1c..9d97e35 100644 --- a/board.c +++ b/board.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/distributed/distributed.c b/distributed/distributed.c index babbd76..f5dae52 100644 --- a/distributed/distributed.c +++ b/distributed/distributed.c @@ -71,7 +71,6 @@ #include #include #include -#include #include #include @@ -315,8 +314,8 @@ distributed_genmove(struct engine *e, struct board *b, struct time_info *ti, /* Combined move stats from all slaves, only for children * of the root node, plus 2 for pass and resign. */ - struct large_stats *stats = alloca((board_size2(b)+2) * sizeof(struct large_stats)); - stats += 2; + struct large_stats stats_array[board_size2(b) + 2], *stats; + stats = &stats_array[2]; protocol_lock(); clear_receive_queue(); diff --git a/uct/uct.c b/uct/uct.c index 385ee5d..1bbe15d 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -95,9 +95,8 @@ uct_prepare_move(struct uct *u, struct board *b, enum stone color) static void dead_group_list(struct uct *u, struct board *b, struct move_queue *mq) { - struct group_judgement gj; - gj.thres = GJ_THRES; - gj.gs = alloca(board_size2(b) * sizeof(gj.gs[0])); + enum gj_state gs_array[board_size2(b)]; + struct group_judgement gj = { .thres = GJ_THRES, .gs = gs_array }; board_ownermap_judge_groups(b, &u->ownermap, &gj); groups_of_status(b, &gj, GS_DEAD, mq); } -- 2.11.4.GIT