summaryrefslogtreecommitdiff
path: root/tools/virtual.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-09-01 16:50:22 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-09-01 16:51:27 +0100
commit3f03cafcb5f1a5b5a23006ced78a4db5ff6659fb (patch)
tree48592e5cf026394b603e73386b0d307b00c10969 /tools/virtual.c
parent7e6472cfccb66d961efa3acbdbfa4057413cbcaf (diff)
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 <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools/virtual.c')
-rw-r--r--tools/virtual.c10
1 files 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));