lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r897557 - in /lucene/lucy/trunk/core/Lucy/Object: ByteBuf.c CharBuf.c
Date Sat, 09 Jan 2010 21:36:39 GMT
Author: marvin
Date: Sat Jan  9 21:36:39 2010
New Revision: 897557

URL: http://svn.apache.org/viewvc?rev=897557&view=rev
Log:
Make it possible to use BB_Deserialize and CB_Deserialize to read values into
fully-fleshed out existing objects, rather than just newly allocated blanks
from VTable_Make_Obj().

Modified:
    lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c
    lucene/lucy/trunk/core/Lucy/Object/CharBuf.c

Modified: lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c?rev=897557&r1=897556&r2=897557&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c (original)
+++ lucene/lucy/trunk/core/Lucy/Object/ByteBuf.c Sat Jan  9 21:36:39 2010
@@ -205,9 +205,6 @@
 {
     const size_t size = InStream_Read_C32(instream);
     self = self ? self : (ByteBuf*)VTable_Make_Obj(BYTEBUF);
-    self->cap  = 0; 
-    self->size = 0;
-    self->buf  = NULL;
     SI_maybe_grow(self, size);
     self->size = size;
     InStream_Read_Bytes(instream, self->buf, size);

Modified: lucene/lucy/trunk/core/Lucy/Object/CharBuf.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Object/CharBuf.c?rev=897557&r1=897556&r2=897557&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Object/CharBuf.c (original)
+++ lucene/lucy/trunk/core/Lucy/Object/CharBuf.c Sat Jan  9 21:36:39 2010
@@ -467,14 +467,14 @@
 CharBuf*
 CB_deserialize(CharBuf *self, InStream *instream)
 {
+    size_t size = InStream_Read_C32(instream);
     self = self ? self : (CharBuf*)VTable_Make_Obj(CHARBUF);
-    self->size = InStream_Read_C32(instream);
-    self->cap  = self->size + 1;
-    self->ptr  = (char*)MALLOCATE(self->cap);
-    InStream_Read_Bytes(instream, self->ptr, self->size);
-    self->ptr[self->size] = '\0';
-    if (!StrHelp_utf8_valid(self->ptr, self->size)) {
-        S_die_invalid_utf8(self->ptr, self->size);
+    SI_maybe_grow(self, size);
+    InStream_Read_Bytes(instream, self->ptr, size);
+    self->size = size;
+    self->ptr[size] = '\0';
+    if (!StrHelp_utf8_valid(self->ptr, size)) {
+        S_die_invalid_utf8(self->ptr, size);
     }
     return self;
 }



Mime
View raw message