lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r885639 - in /lucene/lucy/trunk/core/Lucy: Test/Object/TestByteBuf.c Test/Object/TestVArray.c Util/StringHelper.c
Date Tue, 01 Dec 2009 01:02:35 GMT
Author: marvin
Date: Tue Dec  1 01:02:33 2009
New Revision: 885639

URL: http://svn.apache.org/viewvc?rev=885639&view=rev
Log:
Fix a memory leak.  Change a test so that it will throw an exception rather
than segfault on failure.  Use Err in StringHelper.c now that it's available.

Modified:
    lucene/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c
    lucene/lucy/trunk/core/Lucy/Test/Object/TestVArray.c
    lucene/lucy/trunk/core/Lucy/Util/StringHelper.c

Modified: lucene/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c?rev=885639&r1=885638&r2=885639&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Object/TestByteBuf.c Tue Dec  1 01:02:33 2009
@@ -2,6 +2,7 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Test.h"
+#include "Lucy/Test/TestUtils.h"
 #include "Lucy/Test/Object/TestByteBuf.h"
 
 static void
@@ -30,6 +31,9 @@
         "same length");
     ASSERT_FALSE(batch, BB_Equals(wanted, (Obj*)got), 
         "Different content spoils Equals");
+
+    DECREF(got);
+    DECREF(wanted);
 }
 
 static void

Modified: lucene/lucy/trunk/core/Lucy/Test/Object/TestVArray.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Object/TestVArray.c?rev=885639&r1=885638&r2=885639&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Object/TestVArray.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Object/TestVArray.c Tue Dec  1 01:02:33 2009
@@ -87,7 +87,7 @@
     VA_Push(array, (Obj*)CB_newf("c"));
 
     ASSERT_INT_EQ(batch, VA_Get_Size(array), 3, "size after Push");
-    ASSERT_TRUE(batch, NULL != DOWNCAST(VA_Fetch(array, 2), CHARBUF), "Push");
+    ASSERT_TRUE(batch, NULL != CERTIFY(VA_Fetch(array, 2), CHARBUF), "Push");
 
     elem = (CharBuf*)CERTIFY(VA_Shift(array), CHARBUF);
     ASSERT_TRUE(batch, CB_Equals_Str(elem, "a", 1), "Shift");

Modified: lucene/lucy/trunk/core/Lucy/Util/StringHelper.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Util/StringHelper.c?rev=885639&r1=885638&r2=885639&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Util/StringHelper.c (original)
+++ lucene/lucy/trunk/core/Lucy/Util/StringHelper.c Tue Dec  1 01:02:33 2009
@@ -1,12 +1,11 @@
 #define C_LUCY_STRINGHELPER
 #include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
 
 #define LUCY_USE_SHORT_NAMES
 #define CHY_USE_SHORT_NAMES
 
 #include "Lucy/Util/StringHelper.h"
+#include "Lucy/Object/Err.h"
 #include "Lucy/Util/Memory.h"
 
 const u8_t StrHelp_UTF8_SKIP[] = {
@@ -148,9 +147,8 @@
         return 4;
     }
     else {
-        fprintf(stderr, "Illegal Unicode code point: %lu", 
-            (unsigned long)code_point);
-        exit(1);
+        THROW(ERR, "Illegal Unicode code point: %u32", code_point);
+        UNREACHABLE_RETURN(u32_t);
     }
 }
 
@@ -211,9 +209,7 @@
             break;
 
         default:
-            fprintf(stderr, "Invalid UTF-8 header byte: %lu", 
-                (unsigned long)retval);
-            exit(1);
+            THROW(ERR, "Invalid UTF-8 header byte: %x32", retval);
     }
 
     return retval;



Mime
View raw message