Nucleus
Barry Fixed resource leak in VFS c4a1ba4 (3 years, 2 months ago)
diff --git a/object/manager.c b/object/manager.c
index a274408..7e6da04 100644
--- a/object/manager.c
+++ b/object/manager.c
@@ -6,14 +6,22 @@
* controls their instantiation and deletion.
*/
-#include <nucleus/object.h>
+#include <nucleus/kernel.h>
#include <nucleus/memory.h>
-#include <nucleus/panic.h>
+#include <nucleus/object.h>
void init_lock(Spinlock *lock);
void acquire(Spinlock *lock);
void release(Spinlock *lock);
+/* Check the magic of an object */
+int
+check(void *addr)
+{
+ Object *obj = addr;
+ return (obj && obj->magic == OBJECT_MAGIC);
+}
+
/* Obtain a reference to an object */
void *
get(void *addr)
@@ -37,6 +45,7 @@ put(void *addr)
if (obj->type->delete)
obj->type->delete(obj);
remove(obj->type->objects, obj);
+ obj->magic = 0;
if (obj->type->free)
obj->type->free(obj);
else