hlfw.ca

x9dev

Download patch

ref: e20d3e301ae8092ffdc5fa0617caa2b67f5a73ce
parent: 41bcf7ade88e6b6c30f7a5cd1ec60b6f02da94e5
author: halfwit <michaelmisch1985@gmail.com>
date: Sat Oct 10 07:46:38 PDT 2020

Make sure we allocate

--- a/x9dev.c
+++ b/x9dev.c
@@ -151,17 +151,18 @@
     C9tag *cons;
     C9fid cfd;
     C9aux *c;
-    char *path;
 
-    x9di.ctx = calloc(1, sizeof(x9di.ctx));
-    x9di.ctx->begin = ctxbegin;
-    x9di.ctx->end = ctxend;
-    x9di.ctx->read = ctxread;
-    x9di.ctx->error = ctxerror;
-    x9di.ctx->aux = c;
-    x9di.ctx->r = x9r;
+	c = calloc(1, sizeof(*c));
+	c->ctx = calloc(1, sizeof(c->ctx));
+	c->ctx->read = ctxread;
+	c->ctx->begin = ctxbegin;
+	c->ctx->end = ctxend;
+	c->ctx->error = ctxerror;
+	c->ctx->aux = c;
+    c->ctx->r = x9r;
 
     /* We have 9p, we can init */
+    //if(initdraw(c->ctx, "x9dev")< 0)
     if(initdraw(NULL, 0, "x9dev") < 0)
         FatalError("can't open display");
 
@@ -171,6 +172,7 @@
     x9di.dpi = 100;
     x9di.bpl = bytesperline(Rect(0, 0, x9di.width, x9di.height), x9di.depth);
     x9di.fb = malloc(x9di.bpl * x9di.height);
+    x9di.ctx = c->ctx;
 
     sprintf(path, "%s/mouse", _display->devdir);
     c9walk(x9di.ctx, &x9di.mouse->tag, 1, x9di.mouse->f, &path);