libical r633 - in trunk: . examples src/libical src/libicalcap src/libicalss src/test
- From: pchen svn gnome org
- To: svn-commits-list gnome org
- Subject: libical r633 - in trunk: . examples src/libical src/libicalcap src/libicalss src/test
- Date: Mon, 18 Feb 2008 07:26:46 +0000 (GMT)
Author: pchen
Date: Mon Feb 18 07:26:45 2008
New Revision: 633
URL: http://svn.gnome.org/viewvc/libical?rev=633&view=rev
Log:
2008-02-14 Chenthill Palanisamy <pchenthill novell com>
Fixes #516408
* examples/access_properties_and_parameters.c (test_properties):
* examples/parse_text.c (parse_text):
* examples/usecases.c (test_values), (test_parameters):
* src/libical/icalcomponent.c (icalcomponent_as_ical_string):
* src/libical/icalduration.c (icaldurationtype_as_ical_string):
* src/libical/icalenums.c (icalenum_reqstat_code):
* src/libical/icallangbind.c
* (icallangbind_property_eval_string),
(icallangbind_quote_as_ical):
* src/libical/icallangbind.h:
* src/libical/icalmemory.c (ring_destroy),
(icalmemory_add_tmp_buffer), (icalmemory_free_ring_byval):
* src/libical/icalmime.c (icalmime_text_end_part):
* src/libical/icalparameter.c (icalparameter_as_ical_string):
* src/libical/icalparser.c (icalparser_parse):
* src/libical/icalperiod.c (icalperiodtype_as_ical_string):
* src/libical/icalperiod.h:
* src/libical/icalproperty.c (fold_property_line),
(icalproperty_as_ical_string),
(icalproperty_get_parameter_as_string),
(icalproperty_get_value_as_string),
(icalproperty_get_property_name):
* src/libical/icalproperty.h:
* src/libical/icalrecur.c (icalrecurrencetype_as_string):
* src/libical/icaltime.c (icaltime_as_ical_string):
* src/libical/icaltime.h:
* src/libical/icaltypes.c (icalreqstattype_as_string):
* src/libical/icaltypes.h:
* src/libical/icalvalue.c (icalvalue_binary_as_ical_string),
(icalvalue_int_as_ical_string),
(icalvalue_utcoffset_as_ical_string),
(icalvalue_string_as_ical_string),
(icalvalue_text_as_ical_string),
(icalvalue_attach_as_ical_string),
(icalvalue_date_as_ical_string),
(icalvalue_datetime_as_ical_string),
(icalvalue_float_as_ical_string),
(icalvalue_geo_as_ical_string),
(icalvalue_datetimeperiod_as_ical_string),
(icalvalue_period_as_ical_string),
(icalvalue_trigger_as_ical_string), (icalvalue_as_ical_string),
(icalvalue_compare), (icalvalue_encode_ical_string):
* src/libical/icalvalue.h:
* src/libicalcap/client.c (msg_handler), (main):
* src/libicalcap/icalcap_rr.c (icalcap_message_new_rr),
(icalcap_message_new_reply_rr):
* src/libicalcap/icalcap_utils.c (msg_parse):
* src/libicalss/icalbdbset.c (icalbdbset_commit),
(icalbdbset_get_id):
* src/libicalss/icalclassify.c (icalssutil_is_rescheduled):
* src/libicalss/icalcluster.c (icalcluster_get_component):
* src/libicalss/icalcstpclient.c (icalcstpc_next_output):
* src/libicalss/icalfileset.c (icalfileset_commit),
(icalfileset_get_id):
* src/test/copycluster.c (main):
* src/test/findobj.c (main):
* src/test/icaltestparser.c (main):
* src/test/process.c (send_message), (main):
* src/test/recur.c (main):
* src/test/regression-classify.c (test_classify):
* src/test/regression-component.c (create_simple_component),
(create_new_component), (create_new_component_with_va_args):
* src/test/regression-cxx.cpp:
* src/test/regression-recur.c (test_recur_file):
* src/test/regression-storage.c (test_fileset_extended),
(test_bdbset), (test_dirset_extended):
* src/test/regression.c (test_values), (test_properties),
(test_parameters), (test_components), (test_memory),
(test_dirset),
(test_restriction), (print_occur), (test_recur_parameter_bug),
(test_duration), (test_period), (test_strings),
(test_requeststat),
(do_test_time), (test_overlaps), (test_fblist),
(test_convenience),
(test_recur_parser), (test_x), (test_gauge_compare),
(test_action),
(test_trigger), (test_rdate), (test_langbind),
(test_property_parse), (test_value_parameter),
(test_x_parameter),
(test_x_property), (test_utcoffset), (test_attach), (test_vcal):
* src/test/storage.c (test_fileset), (test_bdbset),
* (test_dirset):
* src/test/stow.c (return_failure), (check_component):
* src/test/testclassify.c (main):
* src/test/testmime.c (main):
* src/test/testvcal.c (main): Do not own the memory which is
* exposed to
the clients. Reduce the size of the ring buffer to 2 as that it
was would
be needed with the changes made.
Modified:
trunk/ChangeLog
trunk/examples/access_properties_and_parameters.c
trunk/examples/parse_text.c
trunk/examples/usecases.c
trunk/src/libical/icalcomponent.c
trunk/src/libical/icalduration.c
trunk/src/libical/icalenums.c
trunk/src/libical/icallangbind.c
trunk/src/libical/icallangbind.h
trunk/src/libical/icalmemory.c
trunk/src/libical/icalmime.c
trunk/src/libical/icalparameter.c
trunk/src/libical/icalparser.c
trunk/src/libical/icalperiod.c
trunk/src/libical/icalperiod.h
trunk/src/libical/icalproperty.c
trunk/src/libical/icalproperty.h
trunk/src/libical/icalrecur.c
trunk/src/libical/icaltime.c
trunk/src/libical/icaltime.h
trunk/src/libical/icaltypes.c
trunk/src/libical/icaltypes.h
trunk/src/libical/icalvalue.c
trunk/src/libical/icalvalue.h
trunk/src/libicalcap/client.c
trunk/src/libicalcap/icalcap_rr.c
trunk/src/libicalcap/icalcap_utils.c
trunk/src/libicalss/icalbdbset.c
trunk/src/libicalss/icalclassify.c
trunk/src/libicalss/icalcluster.c
trunk/src/libicalss/icalcstpclient.c
trunk/src/libicalss/icalfileset.c
trunk/src/test/copycluster.c
trunk/src/test/findobj.c
trunk/src/test/icaltestparser.c
trunk/src/test/process.c
trunk/src/test/recur.c
trunk/src/test/regression-classify.c
trunk/src/test/regression-component.c
trunk/src/test/regression-cxx.cpp
trunk/src/test/regression-recur.c
trunk/src/test/regression-storage.c
trunk/src/test/regression.c
trunk/src/test/storage.c
trunk/src/test/stow.c
trunk/src/test/testclassify.c
trunk/src/test/testmime.c
trunk/src/test/testvcal.c
Modified: trunk/examples/access_properties_and_parameters.c
==============================================================================
--- trunk/examples/access_properties_and_parameters.c (original)
+++ trunk/examples/access_properties_and_parameters.c Mon Feb 18 07:26:45 2008
@@ -103,6 +103,7 @@
icalproperty *prop;
icalparameter *param;
icalvalue *value;
+ char *str;
icalproperty *clone;
@@ -127,7 +128,9 @@
printf("Prop value: %s\n",icalproperty_get_comment(prop));
/* Spit out the property in its RFC 2445 representation */
- printf("As iCAL string:\n %s\n",icalproperty_as_ical_string(prop));
+ str = icalproperty_as_ical_string (prop);
+ printf("As iCAL string:\n %s\n", str);
+ free (str);
/* Make a copy of the property. Caller owns the memory */
clone = icalproperty_new_clone(prop);
@@ -135,7 +138,9 @@
/* Get a reference to the value within the clone property */
value = icalproperty_get_value(clone);
- printf("Value: %s",icalvalue_as_ical_string(value));
+ str = icalvalue_as_ical_string (value);
+ printf("Value: %s", str);
+ free (str);
/* Free the original and the clone */
icalproperty_free(clone);
Modified: trunk/examples/parse_text.c
==============================================================================
--- trunk/examples/parse_text.c (original)
+++ trunk/examples/parse_text.c Mon Feb 18 07:26:45 2008
@@ -54,7 +54,9 @@
if (c != 0){
- printf("%s",icalcomponent_as_ical_string(c));
+ char *temp = icalcomponent_as_ical_string (c);
+ printf("%s", temp);
+ free (temp);
printf("\n---------------\n");
Modified: trunk/examples/usecases.c
==============================================================================
--- trunk/examples/usecases.c (original)
+++ trunk/examples/usecases.c Mon Feb 18 07:26:45 2008
@@ -59,16 +59,21 @@
{
icalvalue *v;
icalvalue *copy;
+ char *str;
v = icalvalue_new_caladdress("cap://value/1");
printf("caladdress 1: %s\n",icalvalue_get_caladdress(v));
icalvalue_set_caladdress(v,"cap://value/2");
printf("caladdress 2: %s\n",icalvalue_get_caladdress(v));
- printf("String: %s\n",icalvalue_as_ical_string(v));
+ str = icalvalue_as_ical_string (v);
+ printf("String: %s\n", str);
+ free (str);
copy = icalvalue_new_clone(v);
- printf("Clone: %s\n",icalvalue_as_ical_string(v));
+ str = icalvalue_as_ical_string (v);
+ printf("Clone: %s\n", str);
+ free (str);
icalvalue_free(v);
icalvalue_free(copy);
@@ -78,12 +83,15 @@
void test_parameters()
{
icalparameter *p;
+ char *str;
p = icalparameter_new_cn("A Common Name");
printf("Common Name: %s\n",icalparameter_get_cn(p));
- printf("As String: %s\n",icalparameter_as_ical_string(p));
+ str = icalparameter_as_ical_string (p);
+ printf("As String: %s\n",str);
+ free (str);
}
Modified: trunk/src/libical/icalcomponent.c
==============================================================================
--- trunk/src/libical/icalcomponent.c (original)
+++ trunk/src/libical/icalcomponent.c Mon Feb 18 07:26:45 2008
@@ -275,7 +275,7 @@
icalcomponent_as_ical_string (icalcomponent* impl)
{
char* buf, *out_buf;
- const char* tmp_buf;
+ char* tmp_buf;
size_t buf_size = 1024;
char* buf_ptr = 0;
pvl_elem itr;
@@ -322,6 +322,7 @@
tmp_buf = icalproperty_as_ical_string(p);
icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
+ free (tmp_buf);
}
@@ -334,6 +335,7 @@
tmp_buf = icalcomponent_as_ical_string(c);
icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf);
+ free (tmp_buf);
}
@@ -342,10 +344,7 @@
icalcomponent_kind_to_string(kind));
icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
- out_buf = icalmemory_tmp_copy(buf);
- free(buf);
-
- return out_buf;
+ return buf;
}
Modified: trunk/src/libical/icalduration.c
==============================================================================
--- trunk/src/libical/icalduration.c (original)
+++ trunk/src/libical/icalduration.c Mon Feb 18 07:26:45 2008
@@ -248,11 +248,7 @@
icalmemory_append_string(&buf, &buf_ptr, &buf_size, "PT0S");
}
- output_line = icalmemory_tmp_copy(buf);
- icalmemory_free_buffer(buf);
-
- return output_line;
-
+ return buf;
}
Modified: trunk/src/libical/icalenums.c
==============================================================================
--- trunk/src/libical/icalenums.c (original)
+++ trunk/src/libical/icalenums.c Mon Feb 18 07:26:45 2008
@@ -113,7 +113,7 @@
major = request_status_map[i].major;
minor = request_status_map[i].minor;
sprintf(tmpbuf, "%i.%i", major, minor);
- return icalmemory_tmp_copy(tmpbuf);
+ return icalmemory_strdup (tmpbuf);
}
}
return NULL;
Modified: trunk/src/libical/icallangbind.c
==============================================================================
--- trunk/src/libical/icallangbind.c (original)
+++ trunk/src/libical/icallangbind.c Mon Feb 18 07:26:45 2008
@@ -157,7 +157,7 @@
#define APPENDC(x) icalmemory_append_char(&buf, &buf_ptr, &buf_size, x);
-const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
+char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
{
char tmp[25];
size_t buf_size = 1024;
@@ -209,7 +209,7 @@
default:
{
- const char* str = icalvalue_as_ical_string(value);
+ char* str = icalvalue_as_ical_string(value);
char* copy = (char*) malloc(strlen(str)+1);
const char *i;
@@ -237,6 +237,7 @@
APPENDC('\'');
free(copy);
+ free (str);
break;
}
@@ -249,8 +250,7 @@
param != 0;
param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)){
- const char* str = icalparameter_as_ical_string(param);
- char *copy = icalmemory_tmp_copy(str);
+ char *copy = icalparameter_as_ical_string (param);
char *v;
if(copy == 0){
@@ -262,6 +262,7 @@
if(v == 0){
+ free (copy);
continue;
}
@@ -277,13 +278,12 @@
APPENDC('\'');
APPENDS(v);
APPENDC('\'');
-
+ free (copy);
}
APPENDC('}');
- icalmemory_add_tmp_buffer(buf);
return buf;
}
@@ -300,7 +300,7 @@
}
-const char* icallangbind_quote_as_ical(const char* str)
+char* icallangbind_quote_as_ical(const char* str)
{
size_t buf_size = 2 * strlen(str);
@@ -310,7 +310,5 @@
result = icalvalue_encode_ical_string(str, buf, buf_size);
- icalmemory_add_tmp_buffer(buf);
-
return buf;
}
Modified: trunk/src/libical/icallangbind.h
==============================================================================
--- trunk/src/libical/icallangbind.h (original)
+++ trunk/src/libical/icallangbind.h Mon Feb 18 07:26:45 2008
@@ -45,10 +45,10 @@
icalparameter* icallangbind_get_next_parameter(icalproperty *prop);
-const char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
+char* icallangbind_property_eval_string(icalproperty* prop, char* sep);
int icallangbind_string_to_open_flag(const char* str);
-const char* icallangbind_quote_as_ical(const char* str);
+char* icallangbind_quote_as_ical(const char* str);
#endif /*__ICALLANGBIND_H__*/
Modified: trunk/src/libical/icalmemory.c
==============================================================================
--- trunk/src/libical/icalmemory.c (original)
+++ trunk/src/libical/icalmemory.c Mon Feb 18 07:26:45 2008
@@ -69,7 +69,7 @@
#include <windows.h>
#endif
-#define BUFFER_RING_SIZE 2500
+#define BUFFER_RING_SIZE 2
#define MIN_BUFFER_SIZE 200
@@ -92,7 +92,10 @@
static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT;
static void ring_destroy(void * buf) {
- if (buf) icalmemory_free_ring_byval((buffer_ring *) buf);
+ if (buf) {
+ icalmemory_free_ring_byval((buffer_ring *) buf);
+ free (buf);
+ }
pthread_setspecific(ring_key, NULL);
}
@@ -161,7 +164,7 @@
}
/* Free buffers as their slots are overwritten */
- if ( br->ring[br->pos] != 0){
+ if (br->ring [br->pos] != 0){
free( br->ring[br->pos]);
}
@@ -198,15 +201,16 @@
return buf;
}
-/** get rid of this buffer ring */
+/** get rid of the contents in buffer ring */
void icalmemory_free_ring_byval(buffer_ring *br) {
int i;
for(i=0; i<BUFFER_RING_SIZE; i++){
if ( br->ring[i] != 0){
free( br->ring[i]);
+ br->ring[i] = 0;
}
}
- free(br);
+ br->pos = 0;
}
void icalmemory_free_ring()
Modified: trunk/src/libical/icalmime.c
==============================================================================
--- trunk/src/libical/icalmime.c (original)
+++ trunk/src/libical/icalmime.c Mon Feb 18 07:26:45 2008
@@ -100,7 +100,6 @@
char *buf;
struct text_part* impl = ( struct text_part*) part;
- icalmemory_add_tmp_buffer(impl->buf);
buf = impl->buf;
free(impl);
Modified: trunk/src/libical/icalparameter.c
==============================================================================
--- trunk/src/libical/icalparameter.c (original)
+++ trunk/src/libical/icalparameter.c Mon Feb 18 07:26:45 2008
@@ -271,10 +271,7 @@
/* Now, copy the buffer to a tmp_buffer, which is safe to give to
the caller without worring about de-allocating it. */
- out_buf = icalmemory_tmp_copy(buf);
- icalmemory_free_buffer(buf);
-
- return out_buf;
+ return buf;
}
Modified: trunk/src/libical/icalparser.c
==============================================================================
--- trunk/src/libical/icalparser.c (original)
+++ trunk/src/libical/icalparser.c Mon Feb 18 07:26:45 2008
@@ -623,6 +623,7 @@
}
} while ( cont );
+ icalmemory_free_ring ();
icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es);
return root;
Modified: trunk/src/libical/icalperiod.c
==============================================================================
--- trunk/src/libical/icalperiod.c (original)
+++ trunk/src/libical/icalperiod.c Mon Feb 18 07:26:45 2008
@@ -104,7 +104,7 @@
}
-const char* icalperiodtype_as_ical_string(struct icalperiodtype p)
+char* icalperiodtype_as_ical_string(struct icalperiodtype p)
{
const char* start;
@@ -121,6 +121,7 @@
start = icaltime_as_ical_string(p.start);
icalmemory_append_string(&buf, &buf_ptr, &buf_size, start);
+ free (start);
if(!icaltime_is_null_time(p.end)){
end = icaltime_as_ical_string(p.end);
@@ -131,9 +132,8 @@
icalmemory_append_char(&buf, &buf_ptr, &buf_size, '/');
icalmemory_append_string(&buf, &buf_ptr, &buf_size, end);
+ free (end);
- icalmemory_add_tmp_buffer(buf);
-
return buf;
}
Modified: trunk/src/libical/icalperiod.h
==============================================================================
--- trunk/src/libical/icalperiod.h (original)
+++ trunk/src/libical/icalperiod.h Mon Feb 18 07:26:45 2008
@@ -41,7 +41,7 @@
struct icalperiodtype icalperiodtype_from_string (const char* str);
-const char* icalperiodtype_as_ical_string(struct icalperiodtype p);
+char* icalperiodtype_as_ical_string(struct icalperiodtype p);
struct icalperiodtype icalperiodtype_null_period(void);
Modified: trunk/src/libical/icalproperty.c
==============================================================================
--- trunk/src/libical/icalproperty.c (original)
+++ trunk/src/libical/icalproperty.c Mon Feb 18 07:26:45 2008
@@ -357,12 +357,7 @@
line_start = next_line_start;
}
- /* Copy it to a temporary buffer, and then free it. */
- out_buf = icalmemory_tmp_buffer (strlen (buf) + 1);
- strcpy (out_buf, buf);
- icalmemory_free_buffer (buf);
-
- return out_buf;
+ return buf;
}
@@ -414,16 +409,13 @@
return kind_string;
}
-const char*
+char*
icalproperty_as_ical_string (icalproperty* prop)
{
icalparameter *param;
/* Create new buffer that we can append names, parameters and a
- value to, and reallocate as needed. Later, this buffer will be
- copied to a icalmemory_tmp_buffer, which is managed internally
- by libical, so it can be given to the caller without fear of
- the caller forgetting to free it */
+ value to, and reallocate as needed. */
const char* property_name = 0;
size_t buf_size = 1024;
@@ -470,10 +462,6 @@
icalparameter_kind kind = icalparameter_isa(param);
kind_string = icalparameter_as_ical_string(param);
- if(kind==ICAL_VALUE_PARAMETER){
- continue;
- }
-
if (kind_string == 0 ) {
icalerror_warn("Got a parameter of unknown kind for the following property");
@@ -481,8 +469,15 @@
continue;
}
+ if(kind==ICAL_VALUE_PARAMETER){
+ free ((char *) kind_string);
+ continue;
+ }
+
+
icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";");
icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string);
+ free ((char *)kind_string);
}
/* Append value */
@@ -492,9 +487,10 @@
value = icalproperty_get_value(prop);
if (value != 0){
- const char *str = icalvalue_as_ical_string(value);
+ char *str = icalvalue_as_ical_string(value);
icalerror_assert((str !=0),"Could not get string representation of a value");
icalmemory_append_string(&buf, &buf_ptr, &buf_size, str);
+ free (str);
} else {
icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value");
@@ -502,9 +498,6 @@
icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline);
- /* Now, copy the buffer to a tmp_buffer, which is safe to give to
- the caller without worring about de-allocating it. */
-
/* We now use a function to fold the line properly every 75 characters. */
out_buf = fold_property_line (buf);
@@ -600,13 +593,13 @@
}
-const char* icalproperty_get_parameter_as_string(icalproperty* prop,
+char* icalproperty_get_parameter_as_string(icalproperty* prop,
const char* name)
{
icalparameter_kind kind;
icalparameter *param;
char* str;
- char* pv;
+ char* pv, *t;
icalerror_check_arg_rz( (prop!=0),"prop");
icalerror_check_arg_rz( (name!=0),"name");
@@ -637,15 +630,18 @@
str = icalparameter_as_ical_string(param);
- pv = strchr(str,'=');
+ t = strchr(str,'=');
- if(pv == 0){
+ if(t == 0){
icalerror_set_errno(ICAL_INTERNAL_ERROR);
+ free (str);
return 0;
}
- return pv+1;
+ pv = strdup (t+1);
+ free (str);
+ return pv;
}
/** @see icalproperty_remove_parameter_by_kind()
@@ -901,7 +897,7 @@
return prop->value;
}
-const char* icalproperty_get_value_as_string(const icalproperty* prop)
+char* icalproperty_get_value_as_string(const icalproperty* prop)
{
icalvalue *value;
@@ -937,7 +933,7 @@
}
-const char* icalproperty_get_property_name(const icalproperty* prop)
+char* icalproperty_get_property_name(const icalproperty* prop)
{
const char* property_name = 0;
@@ -963,10 +959,6 @@
icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name);
}
- /* Add the buffer to the temporary buffer ring -- the caller will
- not have to free the memory. */
- icalmemory_add_tmp_buffer(buf);
-
return buf;
}
Modified: trunk/src/libical/icalproperty.h
==============================================================================
--- trunk/src/libical/icalproperty.h (original)
+++ trunk/src/libical/icalproperty.h Mon Feb 18 07:26:45 2008
@@ -49,7 +49,7 @@
icalproperty* icalproperty_new_from_string(const char* str);
-const char* icalproperty_as_ical_string(icalproperty* prop);
+char* icalproperty_as_ical_string(icalproperty* prop);
void icalproperty_free(icalproperty* prop);
@@ -61,7 +61,7 @@
void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter);
void icalproperty_set_parameter_from_string(icalproperty* prop,
const char* name, const char* value);
-const char* icalproperty_get_parameter_as_string(icalproperty* prop,
+char* icalproperty_get_parameter_as_string(icalproperty* prop,
const char* name);
void icalproperty_remove_parameter(icalproperty* prop,
@@ -90,7 +90,7 @@
void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind);
icalvalue* icalproperty_get_value(const icalproperty* prop);
-const char* icalproperty_get_value_as_string(const icalproperty* prop);
+char* icalproperty_get_value_as_string(const icalproperty* prop);
/* Deal with X properties */
@@ -101,7 +101,7 @@
* string, or the value of _get_x_name if the type is and X
* property
*/
-const char* icalproperty_get_property_name (const icalproperty* prop);
+char* icalproperty_get_property_name (const icalproperty* prop);
icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value);
Modified: trunk/src/libical/icalrecur.c
==============================================================================
--- trunk/src/libical/icalrecur.c (original)
+++ trunk/src/libical/icalrecur.c Mon Feb 18 07:26:45 2008
@@ -511,7 +511,7 @@
return 0;
}
- str = (char*)icalmemory_tmp_buffer(buf_sz);
+ str = (char*)icalmemory_new_buffer(buf_sz);
str_p = str;
icalmemory_append_string(&str,&str_p,&buf_sz,"FREQ=");
Modified: trunk/src/libical/icaltime.c
==============================================================================
--- trunk/src/libical/icaltime.c (original)
+++ trunk/src/libical/icaltime.c Mon Feb 18 07:26:45 2008
@@ -448,7 +448,7 @@
* Return a string represention of the time, in RFC2445 format. The
* string is owned by libical
*/
-const char* icaltime_as_ical_string(const struct icaltimetype tt)
+char* icaltime_as_ical_string(const struct icaltimetype tt)
{
size_t size = 17;
char* buf = icalmemory_new_buffer(size);
@@ -466,10 +466,7 @@
tt.hour,tt.minute,tt.second);
}
- icalmemory_add_tmp_buffer(buf);
-
return buf;
-
}
/**
Modified: trunk/src/libical/icaltime.h
==============================================================================
--- trunk/src/libical/icaltime.h (original)
+++ trunk/src/libical/icaltime.h Mon Feb 18 07:26:45 2008
@@ -180,9 +180,8 @@
time_t icaltime_as_timet_with_zone(const struct icaltimetype tt,
const icaltimezone *zone);
-/** Return a string represention of the time, in RFC2445 format. The
- string is owned by libical */
-const char* icaltime_as_ical_string(const struct icaltimetype tt);
+/** Return a string represention of the time, in RFC2445 format. */
+char* icaltime_as_ical_string(const struct icaltimetype tt);
/** @brief Return the timezone */
const icaltimezone *icaltime_get_timezone(const struct icaltimetype t);
Modified: trunk/src/libical/icaltypes.c
==============================================================================
--- trunk/src/libical/icaltypes.c (original)
+++ trunk/src/libical/icaltypes.c Mon Feb 18 07:26:45 2008
@@ -164,11 +164,11 @@
}
-const char* icalreqstattype_as_string(struct icalreqstattype stat)
+char* icalreqstattype_as_string(struct icalreqstattype stat)
{
char *temp;
- temp = (char*)icalmemory_tmp_buffer(TEMP_MAX);
+ temp = (char*)icalmemory_new_buffer(TEMP_MAX);
icalerror_check_arg_rz((stat.code != ICAL_UNKNOWN_STATUS),"Status");
Modified: trunk/src/libical/icaltypes.h
==============================================================================
--- trunk/src/libical/icaltypes.h (original)
+++ trunk/src/libical/icaltypes.h Mon Feb 18 07:26:45 2008
@@ -76,7 +76,7 @@
};
struct icalreqstattype icalreqstattype_from_string(const char* str);
-const char* icalreqstattype_as_string(struct icalreqstattype);
+char* icalreqstattype_as_string(struct icalreqstattype);
Modified: trunk/src/libical/icalvalue.c
==============================================================================
--- trunk/src/libical/icalvalue.c (original)
+++ trunk/src/libical/icalvalue.c Mon Feb 18 07:26:45 2008
@@ -747,7 +747,7 @@
data = icalvalue_get_binary(value);
- str = (char*)icalmemory_tmp_buffer(60);
+ str = (char*)icalmemory_new_buffer(60);
sprintf(str,"icalvalue_binary_as_ical_string is not implemented yet");
return str;
@@ -758,7 +758,7 @@
static char* icalvalue_int_as_ical_string(const icalvalue* value) {
int data;
- char* str = (char*)icalmemory_tmp_buffer(MAX_INT_DIGITS);
+ char* str = (char*)icalmemory_new_buffer(MAX_INT_DIGITS);
icalerror_check_arg_rz( (value!=0),"value");
@@ -773,7 +773,7 @@
{
int data,h,m,s;
char sign;
- char* str = (char*)icalmemory_tmp_buffer(9);
+ char* str = (char*)icalmemory_new_buffer(9);
icalerror_check_arg_rz( (value!=0),"value");
@@ -804,7 +804,7 @@
icalerror_check_arg_rz( (value!=0),"value");
data = value->data.v_string;
- str = (char*)icalmemory_tmp_buffer(strlen(data)+1);
+ str = (char*)icalmemory_new_buffer(strlen(data)+1);
strcpy(str,data);
@@ -828,7 +828,6 @@
static char* icalvalue_text_as_ical_string(const icalvalue* value) {
char *str;
char *str_p;
- char *rtrn;
const char *p;
size_t buf_sz;
@@ -887,11 +886,7 @@
icalmemory_append_char(&str,&str_p,&buf_sz,'\0');
- rtrn = icalmemory_tmp_copy(str);
-
- icalmemory_free_buffer(str);
-
- return rtrn;
+ return str;
}
@@ -909,10 +904,10 @@
const char *url;
url = icalattach_get_url (a);
- str = icalmemory_tmp_buffer (strlen (url) + 1);
+ str = icalmemory_new_buffer (strlen (url) + 1);
strcpy (str, url);
return str;
- } else
+ } else
return icalvalue_binary_as_ical_string (value);
}
@@ -957,7 +952,7 @@
icalerror_check_arg_rz( (value!=0),"value");
data = icalvalue_get_date(value);
- str = (char*)icalmemory_tmp_buffer(9);
+ str = (char*)icalmemory_new_buffer(9);
str[0] = 0;
print_date_to_string(str,&data);
@@ -972,7 +967,7 @@
print_time_to_string(str,data);
}
-static const char* icalvalue_datetime_as_ical_string(const icalvalue* value) {
+static char* icalvalue_datetime_as_ical_string(const icalvalue* value) {
struct icaltimetype data;
char* str;
@@ -989,7 +984,7 @@
data = icalvalue_get_datetime(value);
- str = (char*)icalmemory_tmp_buffer(20);
+ str = (char*)icalmemory_new_buffer(20);
str[0] = 0;
@@ -1006,7 +1001,7 @@
icalerror_check_arg_rz( (value!=0),"value");
data = icalvalue_get_float(value);
- str = (char*)icalmemory_tmp_buffer(15);
+ str = (char*)icalmemory_new_buffer(15);
sprintf(str,"%f",data);
@@ -1021,14 +1016,14 @@
data = icalvalue_get_geo(value);
- str = (char*)icalmemory_tmp_buffer(25);
+ str = (char*)icalmemory_new_buffer(25);
sprintf(str,"%f;%f",data.lat,data.lon);
return str;
}
-static const char* icalvalue_datetimeperiod_as_ical_string(const icalvalue* value) {
+static char* icalvalue_datetimeperiod_as_ical_string(const icalvalue* value) {
struct icaldatetimeperiodtype dtp = icalvalue_get_datetimeperiod(value);
icalerror_check_arg_rz( (value!=0),"value");
@@ -1040,7 +1035,7 @@
}
}
-static const char* icalvalue_period_as_ical_string(const icalvalue* value) {
+static char* icalvalue_period_as_ical_string(const icalvalue* value) {
struct icalperiodtype data;
icalerror_check_arg_rz( (value!=0),"value");
data = icalvalue_get_period(value);
@@ -1049,7 +1044,7 @@
}
-static const char* icalvalue_trigger_as_ical_string(const icalvalue* value) {
+static char* icalvalue_trigger_as_ical_string(const icalvalue* value) {
struct icaltriggertype data;
@@ -1064,7 +1059,7 @@
}
-const char*
+char*
icalvalue_as_ical_string(const icalvalue* value)
{
if(value == 0){
@@ -1133,14 +1128,14 @@
case ICAL_TRANSP_VALUE:
case ICAL_CLASS_VALUE:
if(value->x_value !=0){
- return icalmemory_tmp_copy(value->x_value);
+ return icalmemory_strdup (value->x_value);
}
- return icalproperty_enum_to_string(value->data.v_enum);
+ return icalmemory_strdup (icalproperty_enum_to_string(value->data.v_enum));
case ICAL_X_VALUE:
if (value->x_value != 0)
- return icalmemory_tmp_copy(value->x_value);
+ return icalmemory_strdup (value->x_value);
/* FALLTHRU */
@@ -1294,9 +1289,14 @@
case ICAL_RECUR_VALUE:
{
int r;
+ char *temp1, *temp2;
- r = strcmp(icalvalue_as_ical_string(a),
- icalvalue_as_ical_string(b));
+ temp1 = icalvalue_as_ical_string (a);
+ temp2 = icalvalue_as_ical_string (b);
+ r = strcmp(temp1,
+ temp2);
+ free (temp1);
+ free (temp2);
if (r > 0) {
return ICAL_XLICCOMPARETYPE_GREATER;
@@ -1413,6 +1413,7 @@
}
strcpy(szEncText, ptr);
+ free (ptr);
icalvalue_free ((icalvalue*)value);
Modified: trunk/src/libical/icalvalue.h
==============================================================================
--- trunk/src/libical/icalvalue.h (original)
+++ trunk/src/libical/icalvalue.h Mon Feb 18 07:26:45 2008
@@ -50,7 +50,7 @@
int icalvalue_is_valid(const icalvalue* value);
-const char* icalvalue_as_ical_string(const icalvalue* value);
+char* icalvalue_as_ical_string(const icalvalue* value);
icalvalue_kind icalvalue_isa(const icalvalue* value);
Modified: trunk/src/libicalcap/client.c
==============================================================================
--- trunk/src/libicalcap/client.c (original)
+++ trunk/src/libicalcap/client.c Mon Feb 18 07:26:45 2008
@@ -105,8 +105,11 @@
msg_handler(const icalcap_message *capmsg) {
icalcomponent *reply;
+ char *temp;
- g_message("Got: %s", icalcomponent_as_ical_string(capmsg->comp));
+ temp = icalcomponent_as_ical_string (capmsg->comp);
+ g_message("Got: %s", temp);
+ free (temp);
/* FIXME Check it's a GET-CAPABILITY */
@@ -166,8 +169,11 @@
exit(0);
}
- if (verbose)
- g_print("Got %s\n", icalcomponent_as_ical_string(comp));
+ if (verbose) {
+ char *obj = icalcomponent_as_ical_string (comp) ;
+ g_print("Got %s\n", obj);
+ g_free (obj);
+ }
if (comp)
icalcomponent_free(comp);
Modified: trunk/src/libicalcap/icalcap_rr.c
==============================================================================
--- trunk/src/libicalcap/icalcap_rr.c (original)
+++ trunk/src/libicalcap/icalcap_rr.c Mon Feb 18 07:26:45 2008
@@ -391,7 +391,7 @@
icalcap_message_new_rr(const icalcap *cap, const icalcomponent *comp) {
struct _icalcap_message_rr *ret;
- gchar *str;
+ gchar *str, *obj;
if (comp == NULL) {
/* FIXME return an error */
@@ -400,9 +400,11 @@
ret = _icalcap_message_new_from_component_rr(cap, ICALCAP_MESSAGE_CMD, NULL);
+ obj = icalcomponent_as_ical_string (comp);
str = g_strdup_printf("%s\n\n%s",
"Content-Type: text/calendar",
- icalcomponent_as_ical_string(comp));
+ obj);
+ free (obj);
ret->msg = rr_message_static_new(RR_FRAME_TYPE_MSG, str, strlen(str), TRUE);
@@ -436,10 +438,14 @@
for (cc = icalcomponent_get_first_component(comp,
ICAL_VCALENDAR_COMPONENT);
+
cc != NULL;
cc = icalcomponent_get_next_component(comp,
ICAL_VCALENDAR_COMPONENT)) {
- g_string_append(str, icalcomponent_as_ical_string(cc));
+ char *obj;
+ obj = icalcomponent_as_ical_string (cc);
+ ig_string_append(str, obj);
+ free (obj);
}
ret->msg = rr_message_static_new(RR_FRAME_TYPE_RPY, str->str, strlen(str->str), TRUE);
Modified: trunk/src/libicalcap/icalcap_utils.c
==============================================================================
--- trunk/src/libicalcap/icalcap_utils.c (original)
+++ trunk/src/libicalcap/icalcap_utils.c Mon Feb 18 07:26:45 2008
@@ -60,6 +60,7 @@
icalparameter *param;
icalvalue *value;
RRCAPCmdArgs *ret = g_new0(RRCAPCmdArgs, 1);
+ char *str;
ret->comp = comp;
@@ -70,8 +71,10 @@
goto FAILED;
}
if ((value = icalproperty_get_value(prop)) == NULL) {
+ str = icalproperty_as_ical_string (prop);
rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
- "CMD has no value", icalproperty_as_ical_string(prop));
+ "CMD has no value", str);
+ free (str);
goto FAILED;
}
ret->cmd = icalvalue_get_cmd(value);
@@ -82,10 +85,12 @@
if ((param = icalproperty_get_first_parameter(prop,
ICAL_ID_PARAMETER)) != NULL) {
if ((ret->id = icalparameter_get_id(param)) == NULL) {
+ str = icalproperty_as_ical_string (prop);
rr_cap_send_error(cap, NULL,
ICAL_9_0_UNRECOGNIZED_COMMAND,
"ID param is garbled",
- icalproperty_as_ical_string(prop));
+ str);
+ free (str);
goto FAILED;
}
}
@@ -95,10 +100,12 @@
ICAL_LATENCY_PARAMETER)) != NULL) {
const char *tmp;
if ((tmp = icalparameter_get_latency(param)) == NULL) {
+ str = icalproperty_as_ical_string (prop);
rr_cap_send_error(cap, NULL,
ICAL_9_0_UNRECOGNIZED_COMMAND,
"LATENCY is garbled",
- icalproperty_as_ical_string(prop));
+ str);
+ free (str);
goto FAILED;
}
@@ -110,18 +117,22 @@
ICAL_ACTIONPARAM_PARAMETER)) != NULL) {
if ((ret->action = icalparameter_get_actionparam(param))
== NULL) {
+ str = icalproperty_as_ical_string (prop);
rr_cap_send_error(cap, NULL,
ICAL_9_0_UNRECOGNIZED_COMMAND,
"ACTION is garbled",
- icalproperty_as_ical_string(prop));
+ str);
+ free (str);
goto FAILED;
}
}
if ((ret->latency >= 0) ^ (ret->action != ICAL_ACTIONPARAM_NONE)) {
+ str = icalproperty_as_ical_string (prop);
rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
"LATENCY and ACTION must be both present",
- icalproperty_as_ical_string(prop));
+ str);
+ free (str);
goto FAILED;
}
Modified: trunk/src/libicalss/icalbdbset.c
==============================================================================
--- trunk/src/libicalss/icalbdbset.c (original)
+++ trunk/src/libicalss/icalbdbset.c Mon Feb 18 07:26:45 2008
@@ -866,6 +866,7 @@
reterr = ICAL_INTERNAL_ERROR;
}
}
+ free (str);
}
if (deadlocked) {
@@ -1098,7 +1099,7 @@
} else {
icalvalue *v;
v = icalproperty_get_value(p);
- id.recurrence_id = strdup(icalvalue_as_ical_string(v));
+ id.recurrence_id = icalvalue_as_ical_string(v);
assert(id.recurrence_id != 0);
}
Modified: trunk/src/libicalss/icalclassify.c
==============================================================================
--- trunk/src/libicalss/icalclassify.c (original)
+++ trunk/src/libicalss/icalclassify.c Mon Feb 18 07:26:45 2008
@@ -267,6 +267,7 @@
{
icalproperty *p1,*p2;
icalcomponent *i1,*i2;
+ char *temp1, *temp2;
int i;
icalproperty_kind kind_array[] = {
@@ -285,6 +286,8 @@
i2 = icalcomponent_get_first_real_component(b);
for(i =0; kind_array[i] != ICAL_NO_PROPERTY; i++){
+ int cmp;
+
p1 = icalcomponent_get_first_property(i1,kind_array[i]);
p2 = icalcomponent_get_first_property(i2,kind_array[i]);
@@ -292,10 +295,16 @@
/* Return true if the property exists in one component and not
the other */
return 1;
- }
+ } else if (!p1 && !p2)
+ continue;
+
+ temp1 = icalproperty_as_ical_string (p1);
+ temp2 = icalproperty_as_ical_string (p2);
- if(p1 && strcmp(icalproperty_as_ical_string(p1),
- icalproperty_as_ical_string(p2)) != 0){
+ cmp = strcmp (temp1, temp2);
+ free (temp1);
+ free (temp2);
+ if(p1 && cmp != 0){
return 1;
}
}
Modified: trunk/src/libicalss/icalcluster.c
==============================================================================
--- trunk/src/libicalss/icalcluster.c (original)
+++ trunk/src/libicalss/icalcluster.c Mon Feb 18 07:26:45 2008
@@ -177,8 +177,11 @@
icalerror_check_arg_rz((impl!=0),"cluster");
if (icalcomponent_isa(impl->data) != ICAL_XROOT_COMPONENT) {
+ char *obj;
icalerror_warn("The top component is not an XROOT");
- fprintf(stderr, "%s\n", icalcomponent_as_ical_string(impl->data));
+ obj = icalcomponent_as_ical_string (impl->data);
+ fprintf(stderr, "%s\n", obj);
+ free (obj);
abort();
}
Modified: trunk/src/libicalss/icalcstpclient.c
==============================================================================
--- trunk/src/libicalss/icalcstpclient.c (original)
+++ trunk/src/libicalss/icalcstpclient.c Mon Feb 18 07:26:45 2008
@@ -114,8 +114,6 @@
impl->next_output = 0;
- icalmemory_add_tmp_buffer(out);
-
return out;
}
Modified: trunk/src/libicalss/icalfileset.c
==============================================================================
--- trunk/src/libicalss/icalfileset.c (original)
+++ trunk/src/libicalss/icalfileset.c Mon Feb 18 07:26:45 2008
@@ -370,10 +370,12 @@
if ( sz != strlen(str)){
perror("write");
+ free (str);
icalerror_set_errno(ICAL_FILE_ERROR);
return ICAL_FILE_ERROR;
}
+ free (str);
write_size += sz;
}
@@ -563,7 +565,7 @@
} else {
icalvalue *v;
v = icalproperty_get_value(p);
- id.recurrence_id = strdup(icalvalue_as_ical_string(v));
+ id.recurrence_id = icalvalue_as_ical_string(v);
assert(id.recurrence_id != 0);
}
Modified: trunk/src/test/copycluster.c
==============================================================================
--- trunk/src/test/copycluster.c (original)
+++ trunk/src/test/copycluster.c Mon Feb 18 07:26:45 2008
@@ -112,8 +112,11 @@
if (itr != 0){
if(tostdout){
+ char *obj;
- printf("--------------\n%s\n",icalcomponent_as_ical_string(itr));
+ obj = icalcomponent_as_ical_string (itr);
+ printf("--------------\n%s\n", obj);
+ free (obj);
} else {
Modified: trunk/src/test/findobj.c
==============================================================================
--- trunk/src/test/findobj.c (original)
+++ trunk/src/test/findobj.c Mon Feb 18 07:26:45 2008
@@ -63,7 +63,9 @@
if(itr != 0){
- printf("%s",icalcomponent_as_ical_string(itr));
+ char *obj = icalcomponent_as_ical_string (itr);
+ printf("%s", obj);
+ free (obj);
}
return 0;
Modified: trunk/src/test/icaltestparser.c
==============================================================================
--- trunk/src/test/icaltestparser.c (original)
+++ trunk/src/test/icaltestparser.c Mon Feb 18 07:26:45 2008
@@ -110,8 +110,12 @@
if (c != 0){
+ char *obj;
+
/*icalcomponent_convert_errors(c);*/
- printf("%s",icalcomponent_as_ical_string(c));
+ obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);
+ free (obj);
printf("\n---------------\n");
icalcomponent_free(c);
}
Modified: trunk/src/test/process.c
==============================================================================
--- trunk/src/test/process.c (original)
+++ trunk/src/test/process.c Mon Feb 18 07:26:45 2008
@@ -35,9 +35,11 @@
void send_message(icalcomponent *reply,const char* this_user)
{
- printf("From: %s\n\n%s\n",this_user,icalcomponent_as_ical_string(reply));
-
+ char *obj;
+ obj = icalcomponent_as_ical_string (reply);
+ printf("From: %s\n\n%s\n",this_user, obj);
+ free (obj);
}
@@ -48,6 +50,7 @@
const char *class_string;
int dont_remove;
icalfileset_options options = {O_RDONLY, 0644, 0};
+ char *obj = NULL;
icalset* f = icalset_new(ICAL_FILE_SET, TEST_DATADIR "/process-incoming.ics", &options);
icalset* trash = icalset_new_file("trash.ics");
@@ -79,8 +82,9 @@
dont_remove = 0;
if(inner == 0){
- printf("Bad component, no inner\n %s\n",
- icalcomponent_as_ical_string(c));
+ obj = icalcomponent_as_ical_string (c);
+ printf("Bad component, no inner\n %s\n", obj);
+ free (obj);
continue;
}
@@ -139,7 +143,9 @@
icalrestriction_check(c);
icalcomponent_convert_errors(c);
- snprintf(temp,1024,"I can't understand the component you sent. \n Here is the component you sent, possibly with error messages:\n %s",icalcomponent_as_ical_string(c));
+ obj = icalcomponent_as_ical_string (c);
+ snprintf(temp,1024,"I can't understand the component you sent. \n Here is the component you sent, possibly with error messages:\n %s", obj);
+ free (obj);
reply = icalmessage_new_error_reply(
c,
@@ -332,20 +338,26 @@
break;
}
case ICAL_XLICCLASS_OBSOLETE: {
+ obj = icalcomponent_as_ical_string (c);
printf(" ** Got an obsolete component:\n%s",
- icalcomponent_as_ical_string(c));
+ obj);
+ free (obj);
/* Send back an error */
break;
}
case ICAL_XLICCLASS_MISSEQUENCED: {
+ obj = icalcomponent_as_ical_string (c);
printf(" ** Got a missequenced component:\n%s",
- icalcomponent_as_ical_string(c));
+ obj);
+ free (obj);
/* Send back an error */
break;
}
case ICAL_XLICCLASS_UNKNOWN: {
+ obj = icalcomponent_as_ical_string (c);
printf(" ** Don't know what to do with this component:\n%s",
- icalcomponent_as_ical_string(c));
+ obj);
+ free (obj);
/* Send back an error */
break;
}
@@ -379,7 +391,9 @@
#endif
if(reply !=0){
- printf("%s\n",icalcomponent_as_ical_string(reply));
+ obj = icalcomponent_as_ical_string (c);
+ printf("%s\n", obj);
+ free (obj);
}
next_c = icalset_get_next_component(f);
@@ -396,8 +410,10 @@
c!=0;
c = icalset_get_next_component(out)){
- printf("%s",icalcomponent_as_ical_string(c));
-
+
+ obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);
+ free (obj);
}
#endif
Modified: trunk/src/test/recur.c
==============================================================================
--- trunk/src/test/recur.c (original)
+++ trunk/src/test/recur.c Mon Feb 18 07:26:45 2008
@@ -103,6 +103,7 @@
struct icaltimetype start = icaltime_from_timet(1,0);
struct icaltimetype end = icaltime_today();
+ char *str;
@@ -111,14 +112,18 @@
rrule = icalcomponent_get_first_property(itr,ICAL_RRULE_PROPERTY);
if (desc == 0 || dtstart == 0 || rrule == 0){
+ char *obj = icalcomponent_as_ical_string (itr);
printf("\n******** Error in input component ********\n");
printf("The following component is malformed:\n %s\n",
- icalcomponent_as_ical_string(itr));
+ obj);
+ free (obj);
continue;
}
printf("\n\n#### %s\n",icalproperty_get_description(desc));
- printf("#### %s\n",icalvalue_as_ical_string(icalproperty_get_value(rrule)));
+ str = icalvalue_as_ical_string (icalproperty_get_value (rrule));
+ printf("#### %s\n", str);
+ free (str);
recur = icalproperty_get_rrule(rrule);
start = icalproperty_get_dtstart(dtstart);
Modified: trunk/src/test/regression-classify.c
==============================================================================
--- trunk/src/test/regression-classify.c (original)
+++ trunk/src/test/regression-classify.c Mon Feb 18 07:26:45 2008
@@ -144,8 +144,13 @@
int_is(msg, error_count, 0);
if (error_count !=0) {
- if (VERBOSE) printf("----- Component has errors ------- \n%s-----------------\n",
- icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("----- Component has errors ------- \n%s-----------------\n",
+ obj);
+ free (obj);
+
+ }
}
/* Use one of the icalcomponent convenience routines to get
Modified: trunk/src/test/regression-component.c
==============================================================================
--- trunk/src/test/regression-component.c (original)
+++ trunk/src/test/regression-component.c Mon Feb 18 07:26:45 2008
@@ -26,8 +26,11 @@
bogus = icalcomponent_get_first_property(calendar,ICAL_DTSTART_PROPERTY);
ok("bogus dtstart not found", (bogus == NULL));
- if (VERBOSE && calendar)
- printf("%s\n",icalcomponent_as_ical_string(calendar));
+ if (VERBOSE && calendar) {
+ char *obj = icalcomponent_as_ical_string (calendar);
+ printf("%s\n", obj);
+ free (obj);
+ }
icalcomponent_free(calendar);
}
@@ -81,7 +84,7 @@
struct icaltimetype atime = icaltime_from_timet( 1023398689, 0);
struct icaldatetimeperiodtype rtime;
icalproperty* property;
- char *calendar_as_string;
+ char *calendar_as_string = 0;
rtime.period.start = icaltime_from_timet( 1023398689,0);
rtime.period.end = icaltime_from_timet( 1023409689,0);
@@ -279,12 +282,13 @@
create_new_component_str);
if (VERBOSE && calendar)
- printf("%s\n",icalcomponent_as_ical_string(calendar));
+ printf("%s\n",calendar_as_string);
if (calendar)
icalcomponent_free(calendar);
-
+ if (calendar_as_string)
+ free (calendar_as_string);
}
/* Create a new component, using the va_args list */
@@ -367,8 +371,11 @@
);
ok("creating a complex vcalendar", (calendar != NULL));
- if (VERBOSE && calendar)
+ if (VERBOSE && calendar) {
+ char *obj = icalcomponent_as_ical_string (calendar);
printf("%s\n",icalcomponent_as_ical_string(calendar));
+ free (obj);
+ }
icalcomponent_free(calendar);
Modified: trunk/src/test/regression-cxx.cpp
==============================================================================
--- trunk/src/test/regression-cxx.cpp (original)
+++ trunk/src/test/regression-cxx.cpp Mon Feb 18 07:26:45 2008
@@ -23,6 +23,7 @@
ICalProperty *endProp = new ICalProperty(ICAL_DTEND_PROPERTY);
ICalProperty *locationProp = new ICalProperty(ICAL_LOCATION_PROPERTY);
ICalProperty *descProp = new ICalProperty(ICAL_DESCRIPTION_PROPERTY);
+ char *str;
ok("Valid SUMMARY Property", (summProp != 0));
ok("Valid DTSTART Property", (startProp != 0));
@@ -54,12 +55,12 @@
vEvent->get_summary(),
"jon said: change dir to c:\\rest\\test\\nest to get the file called <foo.dat>\nthis should be in the next line.");
- is ("vEvent->get_dtstart()",
- icaltime_as_ical_string(vEvent->get_dtstart()),
+ str = icaltime_as_ical_string (vEvent->get_dtstart ());
+ is ("vEvent->get_dtstart()", str,
"20011221T180000Z");
- is ("vEvent->get_dtend()",
- icaltime_as_ical_string(vEvent->get_dtend()),
+ str = icaltime_as_ical_string (vEvent->get_dtend ());
+ is ("vEvent->get_dtend()", str,
"20020101T080000Z");
ok ("vEvent->as_ical_string()",
@@ -67,8 +68,12 @@
if (VERBOSE) {
printf("Summary: %s\n", vEvent->get_summary());
- printf("DTSTART: %s\n", icaltime_as_ical_string(vEvent->get_dtstart()));
- printf("DTEND: %s\n", icaltime_as_ical_string(vEvent->get_dtend()));
+ str = icaltime_as_ical_string (vEvent->get_dtstart ());
+ printf("DTSTART: %s\n", str);
+ free (str);
+ str = icaltime_as_ical_string (vEvent->get_dtend ());
+ printf("DTEND: %s\n", str );
+ free (str);
printf("LOCATION: %s\n", vEvent->get_location());
printf("DESCRIPTION: %s\n", vEvent->get_description());
Modified: trunk/src/test/regression-recur.c
==============================================================================
--- trunk/src/test/regression-recur.c (original)
+++ trunk/src/test/regression-recur.c Mon Feb 18 07:26:45 2008
@@ -152,8 +152,12 @@
continue;
}
if (VERBOSE) {
+ char *str;
+
printf("\n\n#### %s\n",desc_str);
- printf("#### %s\n",icalvalue_as_ical_string(icalproperty_get_value(rrule)));
+ str = icalvalue_as_ical_string(icalproperty_get_value(rrule));
+ printf("#### %s\n", str);
+ free (str);
}
recur = icalproperty_get_rrule(rrule);
Modified: trunk/src/test/regression-storage.c
==============================================================================
--- trunk/src/test/regression-storage.c (original)
+++ trunk/src/test/regression-storage.c Mon Feb 18 07:26:45 2008
@@ -145,6 +145,7 @@
int count=0;
struct icaltimetype start, end;
icalcomponent *c,*clone, *itr;
+ char *temp1, *temp2;
icalsetiter iter;
start = icaltime_from_timet( time(0),0);
@@ -221,9 +222,14 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- if (VERBOSE)
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ if (VERBOSE) {
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
+ }
}
@@ -270,9 +276,12 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
-
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+
+ temp1 = icalproperty_as_ical_string (dtstart) ;
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
}
@@ -300,7 +309,7 @@
int num_components=0;
int szdata_len=0;
int ret=0;
- char *subdb, *szdata, *szpacked_data;
+ char *subdb, *szdata, *szpacked_data, *temp1, *temp2;
char uid[255];
struct icaltimetype start, end;
icalcomponent *c,*clone, *itr;
@@ -424,8 +433,11 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
}
icalset_free(cout);
@@ -475,8 +487,11 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
}
icalset_free(cout);
@@ -745,8 +760,11 @@
ok("Setting DTEND property", (icalerrno == ICAL_NO_ERROR));
assert(icalerrno == ICAL_NO_ERROR);
- if (VERBOSE)
- printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner));
+ if (VERBOSE) {
+ char *obj = icalcomponent_as_ical_string (inner);
+ printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner));
+ free (obj);
+ }
error = icaldirset_add_component(s,
icalcomponent_new_clone(itr));
@@ -769,7 +787,9 @@
printf("Got one! (%d)\n", count++);
if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);;
+ free (obj);
if (icaldirset_add_component(s2,c) == 0){
printf("Failed to write!\n");
}
@@ -786,7 +806,9 @@
c = icaldirset_get_next_component(s)){
if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);
+ free (obj);
} else {
printf("Failed to get component\n");
}
Modified: trunk/src/test/regression.c
==============================================================================
--- trunk/src/test/regression.c (original)
+++ trunk/src/test/regression.c Mon Feb 18 07:26:45 2008
@@ -198,6 +198,7 @@
{
icalvalue *v;
icalvalue *copy;
+ char *str;
v = icalvalue_new_caladdress("cap://value/1");
@@ -209,13 +210,17 @@
is("icalvalue_set_caladdress()",
icalvalue_get_caladdress(v), "cap://value/2");
+ str = icalvalue_as_ical_string (v);
is("icalvalue_as_ical_string()",
- icalvalue_as_ical_string(v), "cap://value/2");
+ str, "cap://value/2");
+ free (str);
copy = icalvalue_new_clone(v);
+ str = icalvalue_as_ical_string (copy);
is("icalvalue_new_clone()",
- icalvalue_as_ical_string(copy), "cap://value/2");
+ str, "cap://value/2");
+ free (str);
icalvalue_free(v);
icalvalue_free(copy);
@@ -224,10 +229,14 @@
int_is("icalvalue_new_boolean(1)", icalvalue_get_boolean(v), 1);
icalvalue_set_boolean(v,2);
ok("icalvalue_set_boolean(2)", (2 == icalvalue_get_boolean(v)));
- is("icalvalue_as_ical_string()", icalvalue_as_ical_string(v), "2");
+ str = icalvalue_as_ical_string (v);
+ is("icalvalue_as_ical_string()", str, "2");
+ free (str);
copy = icalvalue_new_clone(v);
- is("icalvalue_new_clone()", icalvalue_as_ical_string(copy), "2");
+ str = icalvalue_as_ical_string (copy);
+ is("icalvalue_new_clone()", str, "2");
+ free (str);
icalvalue_free(v);
icalvalue_free(copy);
@@ -237,22 +246,30 @@
is("icalvalue_new_x(test)", icalvalue_get_x(v), "test");
icalvalue_set_x(v, "test2");
is("icalvalue_set_x(test2)", icalvalue_get_x(v), "test2");
- is("icalvalue_as_ical_string()", icalvalue_as_ical_string(v), "test2");
+ str = icalvalue_as_ical_string (v);
+ is("icalvalue_as_ical_string()", str, "test2");
+ free (str);
copy = icalvalue_new_clone(v);
+ str = icalvalue_as_ical_string (copy);
is("icalvalue_new_clone()", icalvalue_as_ical_string(copy), "test2");
+ free (str);
icalvalue_free(v);
icalvalue_free(copy);
v = icalvalue_new_date(icaltime_from_timet( 1023404802,0));
- is("icalvalue_new_date()", icalvalue_as_ical_string(v), "20020606T230642");
+ str = icalvalue_as_ical_string (v);
+ is("icalvalue_new_date()", str, "20020606T230642");
+ free (str);
icalvalue_set_date(v,icaltime_from_timet( 1023404802-3600,0));
is("icalvalue_set_date()",icalvalue_as_ical_string(v), "20020606T220642");
copy = icalvalue_new_clone(v);
- is("icalvalue_new_clone()",icalvalue_as_ical_string(v), "20020606T220642");
+ str = icalvalue_as_ical_string (v);
+ is("icalvalue_new_clone()", str, "20020606T220642");
+ free (str);
icalvalue_free(v);
icalvalue_free(copy);
@@ -323,6 +340,7 @@
char test_cn_str[128] = "";
char *test_cn_str_good = "A Common Name 1A Common Name 2A Common Name 3A Common Name 4";
char *test_ical_str_good = "COMMENT;CN=A Common Name 1;CN=A Common Name 2;CN=A Common Name 3;CN=A \n Common Name 4:Another Comment\n";
+ char *temp;
prop = icalproperty_vanew_comment(
"Another Comment",
@@ -345,16 +363,29 @@
is("icalproperty_get_comment()",
icalproperty_get_comment(prop), "Another Comment");
- if (VERBOSE) printf("As iCAL string:\n %s\n",icalproperty_as_ical_string(prop));
-
+ if (VERBOSE) {
+ temp = icalproperty_as_ical_string (prop);
+ printf("As iCAL string:\n %s\n", temp);
+ free (temp);
+ }
+
+ temp = icalproperty_as_ical_string (prop) ;
is("icalproperty_as_ical_string()",
- icalproperty_as_ical_string(prop), test_ical_str_good);
+ temp, test_ical_str_good);
+ free (temp);
clone = icalproperty_new_clone(prop);
- if (VERBOSE) printf("Clone:\n %s\n",icalproperty_as_ical_string(prop));
+ if (VERBOSE) {
+ temp = icalproperty_as_ical_string (prop) ;
+ printf("Clone:\n %s\n",temp);
+ free (temp);
+ }
+
+ temp = icalproperty_as_ical_string (prop);
is("icalproperty_new_clone()",
- icalproperty_as_ical_string(prop), test_ical_str_good);
+ temp, test_ical_str_good);
+ free (temp);
icalproperty_free(clone);
icalproperty_free(prop);
@@ -391,12 +422,14 @@
int i;
int enums[] = {ICAL_CUTYPE_INDIVIDUAL,ICAL_CUTYPE_RESOURCE,ICAL_FBTYPE_BUSY,ICAL_PARTSTAT_NEEDSACTION,ICAL_ROLE_NONPARTICIPANT,ICAL_XLICCOMPARETYPE_LESSEQUAL,ICAL_XLICERRORTYPE_MIMEPARSEERROR,-1};
- char* str1 = "A Common Name";
+ char* str1 = "A Common Name", *str;
p = icalparameter_new_cn(str1);
is("icalparameter_new_cn()", icalparameter_get_cn(p), str1);
- is("icalparameter_as_ical_string()" ,icalparameter_as_ical_string(p),"CN=A Common Name");
+ str = icalparameter_as_ical_string (p);
+ is("icalparameter_as_ical_string()" ,str,"CN=A Common Name");
+ free (str);
icalparameter_free(p);
@@ -446,6 +479,7 @@
{
icalcomponent* c;
icalcomponent* child;
+ char *obj;
c = icalcomponent_vanew(
ICAL_VCALENDAR_COMPONENT,
@@ -476,19 +510,27 @@
0
);
- if (VERBOSE)
- printf("Original Component:\n%s\n\n",icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("Original Component:\n%s\n\n", obj);
+ free (obj);
+ }
child = icalcomponent_get_first_component(c,ICAL_VEVENT_COMPONENT);
ok("test icalcomponent_get_first_component()",
(child != NULL));
- if (VERBOSE)
- printf("Child Component:\n%s\n\n",icalcomponent_as_ical_string(child));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (child);
+ printf("Child Component:\n%s\n\n", obj);
+ free (obj);
+ }
+ obj = icalcomponent_as_ical_string (child);
is("test results of child component",
- icalcomponent_as_ical_string(child), good_child);
+ obj, good_child);
+ free (obj);
icalcomponent_free(c);
}
@@ -514,7 +556,9 @@
char S11[] = "11) That to secure these rights, Governments are instituted among Men, ";
char S12[] = "12) deriving their just powers from the consent of the governed. ";
*/
+ char *f;
+/* Buffer ring size is just 2 so ignore these
char *f, *b1, *b2, *b3, *b4, *b5, *b6, *b7, *b8;
@@ -573,7 +617,7 @@
ok("final buffer size == 806", (bufsize == 806));
- free(f);
+ free(f); */
bufsize = 4;
@@ -626,14 +670,15 @@
free(f);
- for(i=0; i<100; i++){
+/* Buffer size now holds only 2 memory blocks so ignore this
+ for(i=0; i<100; i++){
f = icalmemory_tmp_buffer(bufsize);
assert(f!=0);
memset(f,0,bufsize);
sprintf(f,"%d",i);
- }
+ } */
}
@@ -648,6 +693,7 @@
struct icalperiodtype rtime;
int i;
int count = 0;
+ char *obj;
mkdir("store", 0755);
mkdir("store-new", 0755);
@@ -722,7 +768,9 @@
}
assert(icalerrno == ICAL_NO_ERROR);
- printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(clone));
+ obj = icalcomponent_as_ical_string (clone);
+ printf("\n----------\n%s\n---------\n",obj);
+ free (obj);
error = icaldirset_add_component(s,clone);
@@ -738,10 +786,12 @@
printf("Got one! (%d)\n", count++);
if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
+ obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);;
if (icaldirset_add_component(s2,c) == 0){
printf("Failed to write!\n");
}
+ free (obj);
icalcomponent_free(c);
} else {
printf("Failed to get component\n");
@@ -758,8 +808,10 @@
next = icaldirset_get_next_component(s);
if (c != 0){
+ obj = icalcomponent_as_ical_string (c);
/*icaldirset_remove_component(s,c);*/
- printf("%s", icalcomponent_as_ical_string(c));;
+ printf("%s", obj);;
+ free (obj);
} else {
printf("Failed to get component\n");
}
@@ -915,6 +967,7 @@
str = icalcomponent_as_ical_string(comp);
icalcomponent_free(comp);
+ free (str);
}
@@ -976,11 +1029,14 @@
{
struct icaltimetype next;
icalrecur_iterator* ritr;
+ char *str;
time_t tt = icaltime_as_timet(start);
- printf("#### %s\n",icalrecurrencetype_as_string(&recur));
+ str = icalrecurrencetype_as_string (&recur);
+ printf("#### %s\n",str);
printf("#### %s\n",ctime(&tt ));
+ free (str);
for(ritr = icalrecur_iterator_new(recur,start),
next = icalrecur_iterator_next(ritr);
@@ -1107,6 +1163,7 @@
str = icalcomponent_as_ical_string(icalcomp);
is("parsed matches original", str, (char*)test_icalcomp_str);
if (VERBOSE) printf("%s\n\n",str);
+ free (str);
n_errors = icalcomponent_count_errors (icalcomp);
int_is("no parse errors", n_errors, 0);
@@ -1119,10 +1176,11 @@
p;
p = icalcomponent_get_next_property (icalcomp,
ICAL_XLICERROR_PROPERTY)) {
- const char *str;
+ char *str;
str = icalproperty_as_ical_string (p);
fprintf (stderr, "error: %s\n", str);
+ free (str);
}
}
@@ -1131,8 +1189,10 @@
assert(prop!=NULL);
recur = icalproperty_get_rrule (prop);
-
- if (VERBOSE) printf("%s\n",icalrecurrencetype_as_string(&recur));
+
+ str = icalrecurrencetype_as_string (&recur);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
icalcomponent_free(icalcomp);
}
@@ -1141,25 +1201,36 @@
void test_duration()
{
struct icaldurationtype d;
+ char *str;
d = icaldurationtype_from_string("PT8H30M");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("PT8H30M", icaldurationtype_as_int(d), 30600);
d = icaldurationtype_from_string("-PT8H30M");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("-PT8H30M", icaldurationtype_as_int(d), -30600);
d = icaldurationtype_from_string("PT10H10M10S");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("PT10H10M10S", icaldurationtype_as_int(d), 36610);
d = icaldurationtype_from_string("P7W");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("P7W", icaldurationtype_as_int(d), 4233600);
d = icaldurationtype_from_string("P2DT8H30M");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("P2DT8H30M", icaldurationtype_as_int(d), 203400);
icalerror_errors_are_fatal = 0;
@@ -1167,38 +1238,52 @@
/* Test conversion of bad input */
d = icaldurationtype_from_int(1314000);
- if (VERBOSE) printf("%s %d\n",icaldurationtype_as_ical_string(d),
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s %d\n", str,
icaldurationtype_as_int(d));
- is("1314000", icaldurationtype_as_ical_string(d), "P15DT5H");
+ is("1314000", str, "P15DT5H");
+ free (str);
d = icaldurationtype_from_string("P2W1DT5H");
- if (VERBOSE) printf("%s %d\n",icaldurationtype_as_ical_string(d),
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s %d\n", str,
icaldurationtype_as_int(d));
+ free (str);
int_is("P15DT5H", icaldurationtype_as_int(d), 0);
d = icaldurationtype_from_string("P-2DT8H30M");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("P-2DT8H30M", icaldurationtype_as_int(d), 0);
d = icaldurationtype_from_string("P7W8H");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("P7W8H", icaldurationtype_as_int(d), 0);
d = icaldurationtype_from_string("T10H");
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
int_is("T10H", icaldurationtype_as_int(d), 0);
icalerror_errors_are_fatal = 1;
d = icaldurationtype_from_int(4233600);
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
is("P7W",
- icaldurationtype_as_ical_string(d), "P7W");
+ str, "P7W");
+ free (str);
d = icaldurationtype_from_int(4424400);
- if (VERBOSE) printf("%s\n",icaldurationtype_as_ical_string(d));
+ str = icaldurationtype_as_ical_string (d);
+ if (VERBOSE) printf("%s\n",str);
is("P51DT5H",
- icaldurationtype_as_ical_string(d), "P51DT5H");
+ str, "P51DT5H");
+ free (str);
}
@@ -1206,22 +1291,28 @@
{
struct icalperiodtype p;
icalvalue *v;
- char *str;
+ char *str, *tstr;
str = "19971015T050000Z/PT8H30M";
p = icalperiodtype_from_string(str);
- is(str, icalperiodtype_as_ical_string(p),str);
+ tstr = icalperiodtype_as_ical_string (p);
+ is(str, tstr,str);
+ free (tstr);
str = "19971015T050000Z/19971015T060000Z";
p = icalperiodtype_from_string(str);
- is(str, icalperiodtype_as_ical_string(p),str);
+ tstr = icalperiodtype_as_ical_string (p);
+ is(str, tstr,str);
+ free (tstr);
str = "19970101T120000/PT3H";
v = icalvalue_new_from_string(ICAL_PERIOD_VALUE,str);
- is(str, icalvalue_as_ical_string(v), str);
+ tstr = icalvalue_as_ical_string (v);
+ is(str, tstr, str);
+ free (tstr);
icalvalue_free(v);
}
@@ -1229,23 +1320,34 @@
void test_strings(){
icalvalue *v;
+ char *str;
v = icalvalue_new_text("foo;bar;bats");
- if (VERBOSE)
- printf("%s\n",icalvalue_as_ical_string(v));
+ if (VERBOSE) {
+ str = icalvalue_as_ical_string (v);
+ printf("%s\n", str);
+ free (str);
+ }
+ str = icalvalue_as_ical_string (v);
is("test encoding of 'foo;bar;bats'",
- "foo\\;bar\\;bats", icalvalue_as_ical_string(v));
+ "foo\\;bar\\;bats", str);
+ free (str);
icalvalue_free(v);
v = icalvalue_new_text("foo\\;b\nar\\;ba\tts");
- if (VERBOSE)
- printf("%s\n",icalvalue_as_ical_string(v));
+ if (VERBOSE) {
+ str = icalvalue_as_ical_string (v);
+ printf("%s\n", str);
+ free (str);
+ }
+ str = icalvalue_as_ical_string (v);
is("test encoding of 'foo\\\\;b\\nar\\\\;ba\\tts'",
- "foo\\\\\\;b\\nar\\\\\\;ba\\tts", icalvalue_as_ical_string(v));
+ "foo\\\\\\;b\\nar\\\\\\;ba\\tts", str);
+ free (str);
icalvalue_free(v);
}
@@ -1257,6 +1359,7 @@
icalrequeststatus s;
struct icalreqstattype st, st2;
char temp[1024];
+ char *str;
s = icalenum_num_to_reqstat(2,1);
@@ -1271,20 +1374,26 @@
st.code = s;
st.debug = "booga";
st.desc = 0;
-
+
+ str = icalreqstattype_as_string (st);
is("icalreqstattype_as_string()",
- icalreqstattype_as_string(st),
+ str,
"2.1;Success but fallback taken on one or more property values.;booga");
+ free (str);
st.desc = " A non-standard description";
+ str = icalreqstattype_as_string (st);
is("icalreqstattype_as_string() w/ non standard description",
- icalreqstattype_as_string(st),
+ str,
"2.1; A non-standard description;booga");
+ free (str);
st.desc = 0;
- sprintf(temp,"%s\n",icalreqstattype_as_string(st));
+ str = icalreqstattype_as_string (st);
+ sprintf(temp,"%s\n",str);
+ free (str);
st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;booga");
@@ -1297,24 +1406,31 @@
"Success but fallback taken on one or more property values.");
st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;booga");
- if (VERBOSE) printf("%s\n",icalreqstattype_as_string(st2));
+ str = icalreqstattype_as_string (st2);
+ if (VERBOSE) printf("%s\n", str);
+ free (str);
st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.;");
- if (VERBOSE) printf("%s\n",icalreqstattype_as_string(st2));
+ str = icalreqstattype_as_string (st2);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
st2 = icalreqstattype_from_string("2.1;Success but fallback taken on one or more property values.");
- if (VERBOSE) printf("%s\n",icalreqstattype_as_string(st2));
+ str = icalreqstattype_as_string (st2);
+ if (VERBOSE) printf("%s\n",str);
+ free (str);
st2 = icalreqstattype_from_string("2.1;");
- if (VERBOSE) printf("%s\n",icalreqstattype_as_string(st2));
+ str = icalreqstattype_as_string (st2);
+ if (VERBOSE) printf("%s\n",str);
- is("st2 test again",
- icalreqstattype_as_string(st2),
+ is("st2 test again", str,
"2.1;Success but fallback taken on one or more property values.");
+ free (str);
st2 = icalreqstattype_from_string("2.1");
- is("st2 test #3",
- icalreqstattype_as_string(st2),
+ str = icalreqstattype_as_string (st2);
+ is("st2 test #3", str,
"2.1;Success but fallback taken on one or more property values.");
p = icalproperty_new_from_string("REQUEST-STATUS:2.1;Success but fallback taken on one or more property values.;booga");
@@ -1387,6 +1503,7 @@
icalvalue *v;
short day_of_week,start_day_of_week, day_of_year;
icaltimezone *azone, *utczone;
+ char *str;
char msg[256];
icalerror_errors_are_fatal = 0;
@@ -1551,8 +1668,11 @@
v = icalvalue_new_datetime(ictt);
- if (VERBOSE)
- printf("System time from libical: %s\n",icalvalue_as_ical_string(v));
+ if (VERBOSE) {
+ str = icalvalue_as_ical_string (v);
+ printf("System time from libical: %s\n", str);
+ free (str);
+ }
icalvalue_free(v);
@@ -1880,6 +2000,7 @@
Sat Nov 4 16:00:00 PST 2000 */
time_t hh = 1800; /* one half hour */
+ char *obj;
icalfileset_options options = {O_RDONLY, 0644, 0};
set = icalset_new(ICAL_FILE_SET, TEST_DATADIR "/overlaps.ics", &options);
@@ -1894,7 +2015,11 @@
cset = icalclassify_find_overlaps(set,c);
ok("TODO find overlaps 1", (cset != NULL));
- if (VERBOSE && cset) printf("%s\n",icalcomponent_as_ical_string(cset));
+ if (VERBOSE && cset) {
+ obj = icalcomponent_as_ical_string (cset);
+ printf("%s\n",obj);
+ free (obj);
+ }
if (cset) icalcomponent_free(cset);
if (c) icalcomponent_free(c);
@@ -1910,7 +2035,11 @@
cset = icalclassify_find_overlaps(set,c);
ok("TODO find overlaps 1", cset != NULL);
- if (VERBOSE && cset) printf("%s\n",icalcomponent_as_ical_string(cset));
+ if (VERBOSE && cset) {
+ obj = icalcomponent_as_ical_string (cset);
+ printf("%s\n", obj);
+ free (obj);
+ }
if (cset) icalcomponent_free(cset);
if (c) icalcomponent_free(c);
@@ -1924,7 +2053,11 @@
cset = icalclassify_find_overlaps(set,c);
ok("TODO find overlaps 1", cset != NULL);
- if (VERBOSE && cset) printf("%s\n",icalcomponent_as_ical_string(cset));
+ if (VERBOSE && cset) {
+ obj = icalcomponent_as_ical_string (cset);
+ printf("%s\n", obj);
+ free (obj);
+ }
if (set) icalset_free(set);
if (cset) icalcomponent_free(cset);
@@ -1940,6 +2073,7 @@
icalset *set = icalset_new(ICAL_FILE_SET, TEST_DATADIR "/spanlist.ics", &options);
struct icalperiodtype period;
icalcomponent *comp;
+ char *str;
int * foo;
int i;
@@ -1956,19 +2090,30 @@
period= icalspanlist_next_free_time(sl,
icaltime_from_string("19970801T120000"));
- is("Next Free time start 19970801T120000", icaltime_as_ical_string(period.start), "19970801T120000");
- is("Next Free time end 19980101T000000", icaltime_as_ical_string(period.end), "19980101T000000");
+ str = icaltime_as_ical_string (period.start);
+ is("Next Free time start 19970801T120000", str, "19970801T120000");
+ free (str);
+ str = icaltime_as_ical_string (period.end);
+ is("Next Free time end 19980101T000000", str, "19980101T000000");
+ free (str);
period= icalspanlist_next_free_time(sl, period.end);
- is("Next Free time start 19980101T010000", icaltime_as_ical_string(period.start), "19980101T010000");
- is("Next Free time end 19980102T010000", icaltime_as_ical_string(period.end), "19980102T010000");
+ str = icaltime_as_ical_string (period.start);
+ is("Next Free time start 19980101T010000", str, "19980101T010000");
+ free (str);
+ str = icaltime_as_ical_string (period.end);
+ is("Next Free time end 19980102T010000", str, "19980102T010000");
+ free (str);
- if (VERBOSE) printf("%s\n",
- icalcomponent_as_ical_string(icalspanlist_as_vfreebusy(sl,
+ if (VERBOSE) {
+ str = icalcomponent_as_ical_string(icalspanlist_as_vfreebusy(sl,
"a foo com",
"b foo com")
- ));
+ );
+ printf("%s\n", str);
+ free (str);
+ }
foo = icalspanlist_as_freebusy_matrix(sl,3600);
@@ -2030,13 +2175,17 @@
icaltime_from_string("19970801T120000Z"));
+ str = icaltime_as_ical_string (period.start);
is("Next Free time start 19980101T010000",
- icaltime_as_ical_string(period.start),
+ str,
"19980101T010000");
+ free (str);
+ str = icaltime_as_ical_string (period.end);
is("Next Free time end 19980102T010000",
- icaltime_as_ical_string(period.end),
+ str,
"19980102T010000");
+ free (str);
comp = icalspanlist_as_vfreebusy(sl, "a foo com", "b foo com");
@@ -2062,6 +2211,7 @@
icalcomponent *c;
int duration;
struct icaltimetype tt;
+ char *obj;
c = icalcomponent_vanew(
ICAL_VCALENDAR_COMPONENT,
@@ -2073,7 +2223,11 @@
),
0);
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
@@ -2095,7 +2249,11 @@
),
0);
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
@@ -2121,7 +2279,11 @@
icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M"));
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
@@ -2147,7 +2309,11 @@
icalcomponent_set_dtend(c,icaltime_from_string("19970801T133000Z"));
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
@@ -2173,9 +2339,12 @@
icalcomponent_set_dtstart(c,icaltime_from_string("19970801T120000Z"));
icalcomponent_set_dtend(c,icaltime_from_string("19970801T133000Z"));
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
-
-
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
+
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
ok("Start is 1997-08-01 12:00:00 Z UTC",
@@ -2198,7 +2367,11 @@
icalcomponent_set_dtstart(c,icaltime_from_string("19970801T120000Z"));
icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M"));
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
@@ -2224,7 +2397,11 @@
icaltimezone_get_builtin_timezone("Europe/Rome"));
icalcomponent_set_dtstart(c,tt);
- if (VERBOSE) printf("\n%s\n", icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ obj = icalcomponent_as_ical_string (c);
+ printf("\n%s\n", obj);
+ free (obj);
+ }
icalcomponent_set_duration(c,icaldurationtype_from_string("PT1H30M"));
duration = icaldurationtype_as_int(icalcomponent_get_duration(c))/60;
@@ -2271,16 +2448,19 @@
void test_recur_parser()
{
struct icalrecurrencetype rt;
- char *str;
+ char *str, *rstr;
str = "FREQ=YEARLY;UNTIL=20000131T090000Z;INTERVAL=1;BYDAY=-1TU,3WE,-4FR,SA,SU;BYYEARDAY=34,65,76,78;BYMONTH=1,2,3,4,8";
rt = icalrecurrencetype_from_string(str);
- is(str, icalrecurrencetype_as_string(&rt), str);
+ rstr = icalrecurrencetype_as_string (&rt);
+ is(str, rstr, str);
str = "FREQ=DAILY;COUNT=3;INTERVAL=1;BYDAY=-1TU,3WE,-4FR,SA,SU;BYYEARDAY=34,65,76,78;BYMONTH=1,2,3,4,8";
rt = icalrecurrencetype_from_string(str);
- is(str, icalrecurrencetype_as_string(&rt), str);
+ rstr = icalrecurrencetype_as_string (&rt);
+ is(str, rstr, str);
+ free (rstr);
}
char* ical_strstr(const char *haystack, const char *needle){
@@ -2429,12 +2609,17 @@
icalcomponent *icalcomp;
icalproperty *prop;
struct icalrecurrencetype recur;
+ char *str;
int n_errors;
icalcomp = icalparser_parse_string ((char *) test_icalcomp_str);
assert(icalcomp!=NULL);
- if (VERBOSE) printf("%s\n\n",icalcomponent_as_ical_string(icalcomp));
+ if (VERBOSE) {
+ str = icalcomponent_as_ical_string (icalcomp);
+ printf("%s\n\n",str);
+ free (str);
+ }
n_errors = icalcomponent_count_errors (icalcomp);
int_is("icalparser_parse_string()", n_errors,0);
@@ -2448,10 +2633,11 @@
p;
p = icalcomponent_get_next_property (icalcomp,
ICAL_XLICERROR_PROPERTY)) {
- const char *str;
+ char *str;
str = icalproperty_as_ical_string (p);
fprintf (stderr, "error: %s\n", str);
+ free (str);
}
}
@@ -2461,7 +2647,9 @@
recur = icalproperty_get_rrule (prop);
- if (VERBOSE) printf("%s\n",icalrecurrencetype_as_string(&recur));
+ str = icalrecurrencetype_as_string (&recur);
+ if (VERBOSE) printf("%s\n", str);
+ free (str);
icalcomponent_free(icalcomp);
@@ -2514,8 +2702,8 @@
void test_gauge_compare() {
- icalgauge *g;
- icalcomponent *c;
+ icalgauge *g = 0;
+ icalcomponent *c = 0;
char* str;
/* Equality */
@@ -3046,6 +3234,7 @@
str = icalcomponent_as_ical_string(c);
is("icalcomponent_as_ical_string()", str, ((char*) test_icalcomp_str));
if (VERBOSE) printf("%s\n\n",str);
+ free (str);
p = icalcomponent_get_first_property(c,ICAL_ACTION_PROPERTY);
@@ -3074,7 +3263,7 @@
struct icaltriggertype tr;
icalcomponent *c;
icalproperty *p;
- const char* str;
+ char* str;
static const char test_icalcomp_str[] =
"BEGIN:VEVENT\n"
@@ -3088,8 +3277,10 @@
c = icalparser_parse_string ((char *) test_icalcomp_str);
ok("icalparser_parse_string()", (c!= NULL));
assert(c!=NULL);
-
- is("parsed triggers", icalcomponent_as_ical_string(c), (char*)test_icalcomp_str);
+
+ str = icalcomponent_as_ical_string (c) ;
+ is("parsed triggers", str, (char*)test_icalcomp_str);
+ free (str);
for(p = icalcomponent_get_first_property(c,ICAL_TRIGGER_PROPERTY);
p != 0;
@@ -3097,9 +3288,17 @@
tr = icalproperty_get_trigger(p);
if(!icaltime_is_null_time(tr.time)){
- if (VERBOSE) printf("value=DATE-TIME:%s\n", icaltime_as_ical_string(tr.time));
+ if (VERBOSE) {
+ str = icaltime_as_ical_string (tr.time);
+ printf("value=DATE-TIME:%s\n", str);
+ free (str);
+ }
} else {
- if (VERBOSE) printf("value=DURATION:%s\n", icaldurationtype_as_ical_string(tr.duration));
+ if (VERBOSE) {
+ str = icaldurationtype_as_ical_string (tr.duration);
+ printf("value=DURATION:%s\n", str);
+ free (str);
+ }
}
}
@@ -3109,18 +3308,20 @@
tr.duration = icaldurationtype_null_duration();
tr.time = icaltime_from_string("19970101T120000");
p = icalproperty_new_trigger(tr);
+
str = icalproperty_as_ical_string(p);
-
is("TRIGGER;VALUE=DATE-TIME:19970101T120000", str, "TRIGGER;VALUE=DATE-TIME:19970101T120000\n");
+ free (str);
icalproperty_free(p);
/* TRIGGER, as a DURATION */
tr.time = icaltime_null_time();
tr.duration = icaldurationtype_from_string("P3DT3H50M45S");
p = icalproperty_new_trigger(tr);
- str = icalproperty_as_ical_string(p);
+ str = icalproperty_as_ical_string(p);
is("TRIGGER;VALUE=DURATION:P3DT3H50M45S", str, "TRIGGER;VALUE=DURATION:P3DT3H50M45S\n");
+ free (str);
icalproperty_free(p);
/* TRIGGER, as a DATETIME, VALUE=DATETIME*/
@@ -3128,9 +3329,10 @@
tr.time = icaltime_from_string("19970101T120000");
p = icalproperty_new_trigger(tr);
icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DATETIME));
- str = icalproperty_as_ical_string(p);
+ str = icalproperty_as_ical_string(p);
is("TRIGGER;VALUE=DATE-TIME:19970101T120000", str, "TRIGGER;VALUE=DATE-TIME:19970101T120000\n");
+ free (str);
icalproperty_free(p);
/*TRIGGER, as a DURATION, VALUE=DATETIME */
@@ -3139,9 +3341,10 @@
p = icalproperty_new_trigger(tr);
icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DATETIME ));
- str = icalproperty_as_ical_string(p);
+ str = icalproperty_as_ical_string(p);
is("TRIGGER;VALUE=DURATION:P3DT3H50M45S", str, "TRIGGER;VALUE=DURATION:P3DT3H50M45S\n");
+ free (str);
icalproperty_free(p);
/* TRIGGER, as a DATETIME, VALUE=DURATION*/
@@ -3149,9 +3352,10 @@
tr.time = icaltime_from_string("19970101T120000");
p = icalproperty_new_trigger(tr);
icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DURATION));
- str = icalproperty_as_ical_string(p);
+ str = icalproperty_as_ical_string(p);
is("TRIGGER;VALUE=DATE-TIME:19970101T120000", str, "TRIGGER;VALUE=DATE-TIME:19970101T120000\n");
+ free (str);
icalproperty_free(p);
/*TRIGGER, as a DURATION, VALUE=DURATION */
@@ -3161,8 +3365,8 @@
icalproperty_add_parameter(p,icalparameter_new_value( ICAL_VALUE_DURATION));
str = icalproperty_as_ical_string(p);
-
is("TRIGGER;VALUE=DURATION:P3DT3H50M45S", str, "TRIGGER;VALUE=DURATION:P3DT3H50M45S\n");
+ free (str);
icalproperty_free(p);
@@ -3171,9 +3375,10 @@
tr.time = icaltime_from_string("19970101T120000");
p = icalproperty_new_trigger(tr);
icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY));
- str = icalproperty_as_ical_string(p);
+ str = icalproperty_as_ical_string(p);
is("TRIGGER;VALUE=DATE-TIME:19970101T120000", str, "TRIGGER;VALUE=DATE-TIME:19970101T120000\n");
+ free (str);
icalproperty_free(p);
/*TRIGGER, as a DURATION, VALUE=BINARY */
@@ -3185,6 +3390,7 @@
str = icalproperty_as_ical_string(p);
is("TRIGGER;VALUE=DURATION:P3DT3H50M45S", str, "TRIGGER;VALUE=DURATION:P3DT3H50M45S\n");
+ free (str);
icalproperty_free(p);
}
@@ -3194,7 +3400,7 @@
struct icaldatetimeperiodtype dtp;
icalproperty *p;
- const char* str;
+ char* str;
struct icalperiodtype period;
period.start = icaltime_from_string("19970101T120000");
@@ -3205,10 +3411,11 @@
dtp.time = icaltime_from_string("19970101T120000");
dtp.period = icalperiodtype_null_period();
p = icalproperty_new_rdate(dtp);
- str = icalproperty_as_ical_string(p);
+ str = icalproperty_as_ical_string(p);
is("RDATE as DATE-TIME",
"RDATE;VALUE=DATE-TIME:19970101T120000\n",str);
+ free (str);
icalproperty_free(p);
/* RDATE, as PERIOD */
@@ -3218,6 +3425,7 @@
str = icalproperty_as_ical_string(p);
is("RDATE, as PERIOD", "RDATE;VALUE=PERIOD:19970101T120000/PT3H10M15S\n",str);
+ free (str);
icalproperty_free(p);
/* RDATE, as DATE-TIME, VALUE=DATE-TIME */
@@ -3229,6 +3437,7 @@
is("RDATE, as DATE-TIME, VALUE=DATE-TIME",
"RDATE;VALUE=DATE-TIME:19970101T120000\n",str);
+ free (str);
icalproperty_free(p);
@@ -3240,6 +3449,7 @@
str = icalproperty_as_ical_string(p);
is("RDATE, as PERIOD, VALUE=DATE-TIME",
"RDATE;VALUE=PERIOD:19970101T120000/PT3H10M15S\n",str);
+ free (str);
icalproperty_free(p);
@@ -3252,6 +3462,7 @@
is("RDATE, as DATE-TIME, VALUE=PERIOD",
"RDATE;VALUE=DATE-TIME:19970101T120000\n",str);
+ free (str);
icalproperty_free(p);
@@ -3264,6 +3475,7 @@
is("RDATE, as PERIOD, VALUE=PERIOD",
"RDATE;VALUE=PERIOD:19970101T120000/PT3H10M15S\n",str);
+ free (str);
icalproperty_free(p);
@@ -3276,6 +3488,7 @@
is("RDATE, as DATE-TIME, VALUE=BINARY",
"RDATE;VALUE=DATE-TIME:19970101T120000\n",str);
+ free (str);
icalproperty_free(p);
@@ -3288,6 +3501,7 @@
is("RDAE, as PERIOD, VALUE=BINARY",
"RDATE;VALUE=PERIOD:19970101T120000/PT3H10M15S\n",str);
+ free (str);
icalproperty_free(p);
}
@@ -3296,7 +3510,7 @@
{
icalcomponent *c, *inner;
icalproperty *p;
- char *test_str_parsed;
+ char *test_str_parsed, *temp;
static const char test_str[] =
"BEGIN:VEVENT\n"
"ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A host com\n"
@@ -3337,8 +3551,7 @@
is("parsed version with bad chars, etc",
test_str_parsed,
test_str_parsed_good);
-
-
+ free (test_str_parsed);
inner = icalcomponent_get_inner(c);
for(
@@ -3347,9 +3560,10 @@
p = icallangbind_get_next_property(inner,"ANY")
) {
- const char *str = icallangbind_property_eval_string(p,":");
+ char *str = icallangbind_property_eval_string(p,":");
/** TODO add tests **/
if (VERBOSE) printf("%s\n",str);
+ free (str);
}
@@ -3357,17 +3571,21 @@
icalproperty_set_parameter_from_string(p,"CUTYPE","INDIVIDUAL");
+ temp = icalproperty_as_ical_string (p);
is ("Set attendee parameter",
- icalproperty_as_ical_string(p),
+ temp,
"ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=INDIVIDUAL:MAILTO:\n"
" employee-A host com\n");
+ free (temp);
icalproperty_set_value_from_string(p,"mary foo org","TEXT");
+ temp = icalproperty_as_ical_string (p);
is ("Set attendee parameter value",
- icalproperty_as_ical_string(p),
+ temp,
"ATTENDEE;VALUE=TEXT;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=INDIVIDUAL:\n"
" mary foo org\n");
+ free (temp);
icalcomponent_free(c);
}
@@ -3375,7 +3593,7 @@
void test_property_parse()
{
icalproperty *p;
- const char *str;
+ char *str;
p= icalproperty_new_from_string(
"ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A host com");
@@ -3385,6 +3603,7 @@
str = icalproperty_as_ical_string(p);
if (VERBOSE) printf("%s\n",str);
+ free (str);
icalproperty_free(p);
@@ -3395,6 +3614,7 @@
str = icalproperty_as_ical_string(p);
if (VERBOSE) printf("%s\n",str);
+ free (str);
icalproperty_free(p);
@@ -3421,7 +3641,11 @@
exit (EXIT_FAILURE);
}
- if (VERBOSE) printf("%s",icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);
+ free (obj);
+ }
p = icalcomponent_get_first_property(c,ICAL_DTSTART_PROPERTY);
param = icalproperty_get_first_parameter(p,ICAL_VALUE_PARAMETER);
@@ -3439,11 +3663,16 @@
void test_x_parameter()
{
icalproperty *p;
+ char *temp;
p= icalproperty_new_from_string(
"COMMENT;X-A=1;X-B=2: This is a note");
- if (VERBOSE) printf("%s\n",icalproperty_as_ical_string(p));
+ if (VERBOSE) {
+ temp = icalproperty_as_ical_string (p);
+ printf("%s\n", temp);
+ free (temp);
+ }
ok("COMMENT property",(icalproperty_isa(p) == ICAL_COMMENT_PROPERTY));
is("COMMENT parses param", icalproperty_get_comment(p)," This is a note");
@@ -3453,12 +3682,27 @@
icalproperty_set_parameter_from_string(p,"X-TRUTH", "yes");
icalproperty_set_parameter_from_string(p,"X-HUMOUR", "bad");
- if (VERBOSE) printf("%s\n",icalproperty_as_ical_string(p));
+ if (VERBOSE) {
+ temp = icalproperty_as_ical_string (p);
+ printf("%s\n", temp);
+ free (temp);
+ }
- is("Check X-LIES", icalproperty_get_parameter_as_string(p, "X-LIES"), "no");
- is("Check X-LAUGHS", icalproperty_get_parameter_as_string(p, "X-LAUGHS"), "big");
- is("Check X-TRUTH", icalproperty_get_parameter_as_string(p, "X-TRUTH"), "yes");
- is("Check X-HUMOUR", icalproperty_get_parameter_as_string(p, "X-HUMOUR"), "bad");
+ temp = icalproperty_get_parameter_as_string (p, "X-LIES");
+ is("Check X-LIES", temp, "no");
+ free (temp);
+
+ temp = icalproperty_get_parameter_as_string(p, "X-LAUGHS");
+ is("Check X-LAUGHS", temp, "big");
+ free (temp);
+
+ temp = icalproperty_get_parameter_as_string(p, "X-TRUTH");
+ is("Check X-TRUTH", temp, "yes");
+ free (temp);
+
+ temp = icalproperty_get_parameter_as_string(p, "X-HUMOUR");
+ is("Check X-HUMOUR", temp, "bad");
+ free (temp);
icalproperty_free(p);
}
@@ -3472,7 +3716,11 @@
p= icalproperty_new_from_string(
"X-LIC-PROPERTY: This is a note");
- if (VERBOSE && p) printf("%s\n",icalproperty_as_ical_string(p));
+ if (VERBOSE && p) {
+ char *temp = icalproperty_as_ical_string (p);
+ printf("%s\n",temp);
+ free (temp);
+ }
ok("x-property is correct kind",(icalproperty_isa(p) == ICAL_X_PROPERTY));
is("icalproperty_get_x_name() works",
@@ -3490,7 +3738,11 @@
p = icalproperty_new_from_string("TZOFFSETFROM:-001608");
ok("parse TZOOFSETFROM:-001608", (p!=NULL));
- if (VERBOSE && p) printf("%s\n",icalproperty_as_ical_string(p));
+ if (VERBOSE && p) {
+ char *temp = icalproperty_as_ical_string (p);
+ printf("%s\n", temp);
+ free (temp);
+ }
if (p) icalproperty_free(p);
}
@@ -3508,7 +3760,11 @@
c = icalparser_parse_string ((char *) test_icalcomp_str);
ok("parse simple attachment", (c != NULL));
- if (VERBOSE) printf("%s",icalcomponent_as_ical_string(c));
+ if (VERBOSE) {
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);
+ free (obj);
+ }
if (c) icalcomponent_free(c);
}
@@ -3528,8 +3784,11 @@
ok("Converting to ical component", (comp != 0));
- if (VERBOSE && comp)
- printf("%s\n",icalcomponent_as_ical_string(comp));
+ if (VERBOSE && comp) {
+ char *obj = icalcomponent_as_ical_string (comp);
+ printf("%s\n", obj);
+ free (obj);
+ }
if (comp) icalcomponent_free(comp);
if (vcal) deleteVObject(vcal);
Modified: trunk/src/test/storage.c
==============================================================================
--- trunk/src/test/storage.c (original)
+++ trunk/src/test/storage.c Mon Feb 18 07:26:45 2008
@@ -200,6 +200,7 @@
icalcomponent *event;
icalproperty *dtstart, *dtend;
+ char *temp1, *temp2;
count++;
@@ -208,8 +209,12 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+
+ free (temp1);
+ free (temp2);
}
@@ -243,6 +248,7 @@
icalcomponent *event;
icalproperty *dtstart, *dtend;
+ char *temp1, *temp2;
count++;
@@ -251,8 +257,11 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
}
@@ -392,6 +401,7 @@
icalcomponent *event;
icalproperty *dtstart, *dtend;
+ char *temp1, *temp2;
count++;
@@ -400,8 +410,11 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
}
icalset_free(cout);
@@ -453,7 +466,8 @@
itr = icalbdbset_get_next_component(cout)){
icalcomponent *event;
- icalproperty *dtstart, *dtend;
+ icalproperty *dtstart, *ditend;
+ char *temp1, *temp2;
count++;
@@ -462,8 +476,11 @@
dtstart = icalcomponent_get_first_property(event,ICAL_DTSTART_PROPERTY);
dtend = icalcomponent_get_first_property(event,ICAL_DTEND_PROPERTY);
- printf("%d %s %s\n",count, icalproperty_as_ical_string(dtstart),
- icalproperty_as_ical_string(dtend));
+ temp1 = icalproperty_as_ical_string (dtstart);
+ temp2 = icalproperty_as_ical_string (dtend);
+ printf("%d %s %s\n",count, temp1, temp2);
+ free (temp1);
+ free (temp2);
}
icalset_free(cout);
@@ -681,6 +698,7 @@
itr = icalfileset_get_next_component(cluster)){
icalcomponent *clone, *inner;
icalproperty *p;
+ char *obj;
inner = icalcomponent_get_first_component(itr,ICAL_VEVENT_COMPONENT);
if (inner == 0){
@@ -720,7 +738,9 @@
}
assert(icalerrno == ICAL_NO_ERROR);
- printf("\n----------\n%s\n---------\n",icalcomponent_as_ical_string(inner));
+ obj = icalcomponent_as_ical_string (inner);
+ printf("\n----------\n%s\n---------\n", obj);
+ free (obj);
error = icaldirset_add_component(s,
icalcomponent_new_clone(itr));
@@ -760,10 +780,12 @@
printf("Got one! (%d)\n", count++);
if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);;
if (icaldirset_store(s2,c) == 0){
printf("Failed to write!\n");
}
+ free (obj);
icalcomponent_free(c);
} else {
printf("Failed to get component\n");
@@ -780,7 +802,9 @@
c = icaldirset_get_next_component(s)){
if (c != 0){
- printf("%s", icalcomponent_as_ical_string(c));;
+ char *obj = icalcomponent_as_ical_string (c);
+ printf("%s", obj);;
+ free (obj);
} else {
printf("Failed to get component\n");
}
Modified: trunk/src/test/stow.c
==============================================================================
--- trunk/src/test/stow.c (original)
+++ trunk/src/test/stow.c Mon Feb 18 07:26:45 2008
@@ -254,6 +254,7 @@
icalproperty *organizer_prop = icalcomponent_get_first_property(inner,ICAL_ORGANIZER_PROPERTY);
const char *organizer = icalproperty_get_organizer(organizer_prop);
+ char *obj;
org_addr = strchr(organizer,':');
@@ -276,9 +277,11 @@
exit(1);
}
+ obj = icalcomponent_as_ical_string (comp);
fputs(make_mime(org_addr, local_attendee, "iMIP error",
message, "reply",
- icalcomponent_as_ical_string(comp)),p);
+ obj),p);
+ free (obj);
if (opt->errors == ERRORS_TO_ORGANIZER){
pclose(p);
@@ -483,8 +486,10 @@
icalrestriction_check(comp);
if(errors != icalcomponent_count_errors(comp)){
+ char *obj = icalcomponent_as_ical_string (comp);
snprintf(static_component_error_str,PATH_MAX,
- "The component does not conform to iTIP restrictions.\n Here is the original component; look at the X-LIC-ERROR properties\nfor details\n\n%s",icalcomponent_as_ical_string(comp));
+ "The component does not conform to iTIP restrictions.\n Here is the original component; look at the X-LIC-ERROR properties\nfor details\n\n%s",obj);
+ free (obj);
component_error_str = static_component_error_str;
break;
}
Modified: trunk/src/test/testclassify.c
==============================================================================
--- trunk/src/test/testclassify.c (original)
+++ trunk/src/test/testclassify.c Mon Feb 18 07:26:45 2008
@@ -87,8 +87,10 @@
/* If there are any errors, print out the component */
if(icalcomponent_count_errors(c) != 0){
+ char *obj = icalcomponent_as_ical_string (c);
printf("----- Component has errors ------- \n%s-----------------\n",
- icalcomponent_as_ical_string(c));
+ obj);
+ free (obj);
}
/* Use one of the icalcomponent convenience routines to get
Modified: trunk/src/test/testmime.c
==============================================================================
--- trunk/src/test/testmime.c (original)
+++ trunk/src/test/testmime.c Mon Feb 18 07:26:45 2008
@@ -207,10 +207,13 @@
if(opt.normal == 1){
icalcomponent *c;
+ char *obj;
c = icalmime_parse(read_stream,f);
- printf("%s\n",icalcomponent_as_ical_string(c));
+ obj = icalcomponent_as_ical_string (c);
+ printf("%s\n",obj);
+ free (obj);
icalcomponent_free(c);
@@ -245,6 +248,7 @@
for(j=0; j<opt.count; j++){
+ char *obj;
srand(j);
memset(buf,0,size*2);
@@ -270,7 +274,9 @@
c = icalmime_parse(icalparser_string_line_generator,&d);
- printf("%s\n",icalcomponent_as_ical_string(c));
+ obj = icalcomponent_as_ical_string (c);
+ printf("%s\n", obj);
+ free (obj);
icalcomponent_free(c);
Modified: trunk/src/test/testvcal.c
==============================================================================
--- trunk/src/test/testvcal.c (original)
+++ trunk/src/test/testvcal.c Mon Feb 18 07:26:45 2008
@@ -41,7 +41,7 @@
{
VObject *vcal = 0;
icalcomponent *comp;
- char* file;
+ char* file, *obj;
if (argc != 2){
file = "../../test-data/user-cal.vcf";
@@ -56,7 +56,9 @@
comp = icalvcal_convert(vcal);
- printf("%s\n",icalcomponent_as_ical_string(comp));
+ obj = icalcomponent_as_ical_string (comp);
+ printf("%s\n",obj);
+ free (obj);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]