From 8d56d8a01106a05f1530797fef6a907dc41e3fc4 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 25 Apr 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-04-25 --- port/debugalloc.c | 10 ++++++++++ port/devsdp.c | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/port/debugalloc.c b/port/debugalloc.c index 530c2373b7689513f0f7b90b4aaff140fc27660e..98855eee6a19b7305fc70d574d0a07d8d4206b8f 100644 --- a/port/debugalloc.c +++ b/port/debugalloc.c @@ -12,6 +12,16 @@ #define prev u.s.bhv #define parent u.s.bhp +typedef struct Bhdr Bhdr; + +struct Bhdr { + ulong magic; + ulong size; +}; +enum { + NOT_MAGIC = 0xdeadfa11, +}; + struct Pool { char* name; diff --git a/port/devsdp.c b/port/devsdp.c index 11a3dc082d3f9c03f068eefa2b5243bc1c62a5ea..76af2b26fb17d1c0ac83d9bf6545ed4700eb9b62 100644 --- a/port/devsdp.c +++ b/port/devsdp.c @@ -955,7 +955,7 @@ static void convsetstate(Conv *c, int state) { -if(0)print("convsetstate %s -> %s\n", convstatename[c->state], convstatename[state]); +if(1)print("convsetstate %d: %s -> %s\n", c->id, convstatename[c->state], convstatename[state]); switch(state) { default: @@ -1017,12 +1017,13 @@ static void convderef(Conv *c) { c->ref--; - if(c->ref > 0) + if(c->ref > 0) { return; + } assert(c->ref == 0); assert(c->dataopen == 0); assert(c->controlopen == 0); -//print("convderef: %d: ref == 0!\n", c->id); +if(0)print("convderef: %d: ref == 0!\n", c->id); c->state = CFree; if(c->chan) { cclose(c->chan); @@ -1070,7 +1071,7 @@ convopenchan(Conv *c, char *path) if(c->state != CInit || c->chan != nil) error("already connected"); c->chan = namec(path, Aopen, ORDWR, 0); - c->channame = malloc(strlen(path)+1); + c->channame = smalloc(strlen(path)+1); strcpy(c->channame, path); if(waserror()) { cclose(c->chan); @@ -2300,8 +2301,12 @@ thwackcompinit(Conv *c) compfree(c); c->in.compstate = malloc(sizeof(Unthwack)); + if(c->in.compstate == nil) + error(Enomem); unthwackinit(c->in.compstate); c->out.compstate = malloc(sizeof(Thwack)); + if(c->out.compstate == nil) + error(Enomem); thwackinit(c->out.compstate); c->in.comp = thwackuncomp; c->out.comp = thwackcomp;