summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mixlib/mix_device.c3
-rw-r--r--mixlib/mix_vm.c6
-rw-r--r--mixlib/xmix_device.c11
-rw-r--r--mixlib/xmix_device.h4
4 files changed, 19 insertions, 5 deletions
diff --git a/mixlib/mix_device.c b/mixlib/mix_device.c
index 6870427..2f3f702 100644
--- a/mixlib/mix_device.c
+++ b/mixlib/mix_device.c
@@ -65,8 +65,7 @@ mix_device_delete (mix_device_t *dev)
{
if (dev != NULL)
{
- if (dev->type != mix_dev_CONSOLE && GET_FILE_(dev) != NULL)
- mix_file_delete (GET_FILE_(dev));
+ (dev->vtable->destroy) (dev);
g_free (dev);
}
}
diff --git a/mixlib/mix_vm.c b/mixlib/mix_vm.c
index 39b3e6f..4446bcf 100644
--- a/mixlib/mix_vm.c
+++ b/mixlib/mix_vm.c
@@ -57,6 +57,12 @@ vm_reset_ (mix_vm_t *vm)
mix_src_file_delete (vm->src_file);
vm->src_file = NULL;
}
+ for (k = 0; k < BD_NO_; ++k)
+ if (vm->devices[k] != NULL)
+ {
+ mix_device_delete (vm->devices[k]);
+ vm->devices[k] = NULL;
+ }
bp_clear_all_ (vm);
}
diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c
index c93153a..db343ad 100644
--- a/mixlib/xmix_device.c
+++ b/mixlib/xmix_device.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- xmix_device.c :
* Implementation of the functions declared in xmix_device.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "2001-05-04 23:40:31 jao"
+ * Last change: Time-stamp: "2001-05-07 23:49:31 jao"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -169,8 +169,15 @@ busy_ (const mix_device_t *dev)
return (!mix_io_is_ready (GET_CHANNEL_(dev)));
}
+static void
+destroy_ (mix_device_t *dev)
+{
+ if (dev->type != mix_dev_CONSOLE && GET_FILE_(dev) != NULL)
+ mix_file_delete (GET_FILE_(dev));
+}
+
static mix_device_vtable_t VTABLE_ = {
- write_, read_, ioc_, busy_
+ write_, read_, ioc_, busy_, destroy_
};
const mix_device_vtable_t * DEF_DEV_VTABLE_ = &VTABLE_;
diff --git a/mixlib/xmix_device.h b/mixlib/xmix_device.h
index 4c2866a..f44409f 100644
--- a/mixlib/xmix_device.h
+++ b/mixlib/xmix_device.h
@@ -1,7 +1,7 @@
/* -*-c-*- ---------------- xmix_device.h :
* Protected declarations for mix_device_t
* ------------------------------------------------------------------
- * Last change: Time-stamp: <2001-05-04 23:35:39 jao>
+ * Last change: Time-stamp: <2001-05-07 23:59:35 jao>
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -33,6 +33,7 @@ typedef gboolean (*mix_dev_write_func_t) (mix_device_t *, const mix_word_t *);
typedef gboolean (*mix_dev_read_func_t) (mix_device_t *, mix_word_t *);
typedef gboolean (*mix_dev_ioc_func_t) (mix_device_t *, mix_short_t);
typedef gboolean (*mix_dev_busy_func_t) (const mix_device_t *);
+typedef void (*mix_dev_destroy_t) (mix_device_t *);
typedef struct mix_device_vtable_t
{
@@ -40,6 +41,7 @@ typedef struct mix_device_vtable_t
mix_dev_read_func_t read;
mix_dev_ioc_func_t ioc;
mix_dev_busy_func_t busy;
+ mix_dev_destroy_t destroy;
} mix_device_vtable_t;
/* default vtable */