[Freeswitch-svn] [commit] r11953 - in freeswitch/trunk/libs/sofia-sip: . s2check

FreeSWITCH SVN mikej at freeswitch.org
Thu Feb 12 13:18:20 PST 2009


Author: mikej
Date: Thu Feb 12 15:18:20 2009
New Revision: 11953

Log:
Thu Feb 12 14:27:12 CST 2009  Pekka Pessi <first.last at nokia.com>
  * s2tcase.c: allow multiple calls to s2_select_tests()


Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/s2check/s2check.h
   freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Thu Feb 12 15:18:20 2009
@@ -1 +1 @@
-Thu Feb 12 15:17:34 CST 2009
+Thu Feb 12 15:18:14 CST 2009

Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2check.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/s2check/s2check.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/s2check/s2check.h	Thu Feb 12 15:18:20 2009
@@ -47,6 +47,8 @@
 
 void s2_tcase_add_test(TCase *, TFun, char const *name);
 
+void s2_select_tests(char const *pattern);
+
 SOFIA_END_DECLS
 
 #endif /* S2CHECK_H */

Modified: freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/s2check/s2tcase.c	Thu Feb 12 15:18:20 2009
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include <assert.h>
 
 #include <check.h>
 
@@ -79,7 +80,7 @@
  */
 void s2_select_tests(char const *pattern)
 {
-  size_t i;
+  size_t i, n;
   char *cases, *s, **patterns;
 
   if (!pattern)
@@ -91,10 +92,22 @@
   for (i = 2, s = cases; (s = strchr(s, ',')); s++)
     i++;
 
-  patterns = calloc(i, sizeof *patterns);
+  if (test_patterns != default_patterns) {
+    patterns = (char **)test_patterns;
+    for (n = 0; patterns[n]; n++)
+      ;
+    patterns = realloc(patterns, (n + i) * (sizeof *patterns));
+  }
+  else {
+    n = 0;
+    patterns = malloc(i * (sizeof *patterns));
+  }
+
+  assert(patterns);
+  memset(&patterns[n], 0, i * (sizeof *patterns));
 
   /* Split by commas */
-  for (i = 0, s = cases;; i++) {
+  for (i = n, s = cases;; i++) {
     patterns[i] = s;
     if (s == NULL)
       break;



More information about the Freeswitch-svn mailing list