From 3f03cafcb5f1a5b5a23006ced78a4db5ff6659fb Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 1 Sep 2013 16:50:22 +0100 Subject: [PATCH] intel-virtual-output: Refer to the new memory block after realloc When updating pointers to point into the new memory block after a realloc, it helps to pass the new locations around rather than the old. Signed-off-by: Chris Wilson --- tools/virtual.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/virtual.c b/tools/virtual.c index e2654ff5..a37f4ca3 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -1585,7 +1585,7 @@ static void display_init_randr_hpd(struct display *display) XRRSelectInput(display->dpy, display->root, RROutputChangeNotifyMask); } -static void rebuild_clones(struct context *ctx) +static void rebuild_clones(struct context *ctx, struct clone *new_clones) { int n, m; @@ -1594,7 +1594,7 @@ static void rebuild_clones(struct context *ctx) d->clone = NULL; for (m = 0; m < ctx->nclone; m++) { - struct clone *c = &ctx->clones[m]; + struct clone *c = &new_clones[m]; if (c->dst.display != d) continue; @@ -1603,6 +1603,8 @@ static void rebuild_clones(struct context *ctx) d->clone = c; } } + + ctx->clones = new_clones; } static struct clone *add_clone(struct context *ctx) @@ -1615,9 +1617,7 @@ static struct clone *add_clone(struct context *ctx) return NULL; if (new_clones != ctx->clones) - rebuild_clones(ctx); - - ctx->clones = new_clones; + rebuild_clones(ctx, new_clones); } return memset(&ctx->clones[ctx->nclone++], 0, sizeof(struct clone));