Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: kinosearch: commits

r3759 - trunk/c_src/KinoSearch/Obj

 

 

kinosearch commits RSS feed   Index | Next | Previous | View Threaded


marvin at rectangular

Aug 24, 2008, 9:46 PM

Post #1 of 1 (513 views)
Permalink
r3759 - trunk/c_src/KinoSearch/Obj

Author: creamyg
Date: 2008-08-24 21:46:32 -0700 (Sun, 24 Aug 2008)
New Revision: 3759

Modified:
trunk/c_src/KinoSearch/Obj/FastObj.bp
trunk/c_src/KinoSearch/Obj/FastObj.c
Log:
Fix a memory error in FastObj_Create(), and implement FastObj_Deserialize(),
fixing a nasty weird leak/error. (When FastObj was inheriting Obj's
Deserialize() method, it was being created as a subclass of Obj; i.e. with an
SV ref, rather than with an integer count. The address of this SV was being
treated as a refcount.)


Modified: trunk/c_src/KinoSearch/Obj/FastObj.bp
===================================================================
--- trunk/c_src/KinoSearch/Obj/FastObj.bp 2008-08-25 04:40:46 UTC (rev 3758)
+++ trunk/c_src/KinoSearch/Obj/FastObj.bp 2008-08-25 04:46:32 UTC (rev 3759)
@@ -16,6 +16,9 @@
Foster(FastObj *invoker, const CharBuf *class_name, VirtualTable *vtable,
size_t alloc_size, void *native_blank);

+ public incremented FastObj*
+ Deserialize(FastObj *self, InStream *instream);
+
u32_t
Get_RefCount(FastObj* self);


Modified: trunk/c_src/KinoSearch/Obj/FastObj.c
===================================================================
--- trunk/c_src/KinoSearch/Obj/FastObj.c 2008-08-25 04:40:46 UTC (rev 3758)
+++ trunk/c_src/KinoSearch/Obj/FastObj.c 2008-08-25 04:46:32 UTC (rev 3759)
@@ -6,6 +6,7 @@
#include <string.h>

#include "KinoSearch/Obj/FastObj.h"
+#include "KinoSearch/Store/InStream.h"
#include "KinoSearch/Util/VirtualTable.h"
#include "KinoSearch/Util/DynVirtualTable.h"
#include "KinoSearch/Util/Carp.h"
@@ -26,7 +27,7 @@
}
else {
VirtualTable *subclass_vtable
- = (VirtualTable*)DynVT_singleton((CharBuf*)&class_name, vtable);
+ = (VirtualTable*)DynVT_singleton((CharBuf*)class_name, vtable);
self->_ = REFCOUNT_INC(subclass_vtable);
}
self->ref.count = 1;
@@ -36,6 +37,21 @@
return self;
}

+FastObj*
+FastObj_deserialize(FastObj *self, InStream *instream)
+{
+ CharBuf *class_name = CB_deserialize(NULL, instream);
+ if (!self) {
+ self = (FastObj*)CREATE(class_name, KINO_FASTOBJ);
+ }
+ else {
+ if (!CB_Equals(class_name, (Obj*)self->_->name))
+ CONFESS("Class mismatch: %o %o", class_name, self->_->name);
+ }
+ REFCOUNT_DEC(class_name);
+ return (FastObj*)Obj_init((Obj*)self);
+}
+
chy_u32_t
FastObj_get_refcount(FastObj *self)
{


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits [at] rectangular
http://www.rectangular.com/mailman/listinfo/kinosearch-commits

kinosearch commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.