From: <svn...@op...> - 2009-03-29 18:20:10
|
Author: bricks Date: Sun Mar 29 20:20:04 2009 New Revision: 5430 URL: http://www.opensync.org/changeset/5430 Log: OSyncObjTypeSink had a osync_objtype_sink_get_objformat_sinks functions Changed this function to return a copy of the list Therefore other functions which depend on the list had to be changed too removed osync_objtype_sink_num_objformat_sinks and osync_objtype_sink_nth_objformat_sink from public api refs #975 Modified: trunk/opensync/engine/opensync_mapping_entry_engine.c trunk/opensync/group/opensync_member.c trunk/opensync/group/opensync_member.h trunk/opensync/plugin/opensync_objtype_sink.c trunk/opensync/plugin/opensync_objtype_sink.h trunk/opensync/plugin/opensync_objtype_sink_internals.h trunk/tests/client-tests/check_proxy.c Modified: trunk/opensync/engine/opensync_mapping_entry_engine.c ============================================================================== --- trunk/opensync/engine/opensync_mapping_entry_engine.c Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/opensync/engine/opensync_mapping_entry_engine.c Sun Mar 29 20:20:04 2009 (r5430) @@ -244,7 +244,7 @@ OSyncObjFormatSink *formatsink = osync_objtype_sink_find_objformat_sink(objtype_sink, format); osync_converter_path_set_config(path, osync_objformat_sink_get_config(formatsink)); } - + if (!osync_format_env_convert(formatenv, path, osync_change_get_data(entry_engine->change), error)) { goto error_free_path; } @@ -257,12 +257,14 @@ osync_change_set_objtype(change, objtype); osync_free(objtype); - + osync_list_free(format_sinks); + return TRUE; error_free_path: osync_converter_path_unref(path); error_free_objtype: + osync_list_free(format_sinks); osync_free(objtype); /*error:*/ return FALSE; Modified: trunk/opensync/group/opensync_member.c ============================================================================== --- trunk/opensync/group/opensync_member.c Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/opensync/group/opensync_member.c Sun Mar 29 20:20:04 2009 (r5430) @@ -684,12 +684,7 @@ OSyncObjTypeSink *sink = o->data; OSyncList *format_sinks = osync_objtype_sink_get_objformat_sinks(sink); - /* Use a copy of the list to allow full processing without impact - * on the orignal ObjFormatSink list of OSyncObjTypeSink - */ - OSyncList *copy_format_sinks = osync_list_copy(format_sinks); - - list = osync_list_concat(list, copy_format_sinks); + list = osync_list_concat(list, format_sinks); } return list; @@ -702,8 +697,9 @@ for (o = member->objtypes; o; o = o->next) { OSyncObjTypeSink *sink = o->data; OSyncList *format_sinks = osync_objtype_sink_get_objformat_sinks(sink); - for (; format_sinks; format_sinks = format_sinks->next) { - OSyncObjFormatSink *format_sink = format_sinks->data; + OSyncList *fs = NULL; + for (fs = format_sinks; fs; fs = fs->next) { + OSyncObjFormatSink *format_sink = fs->data; const char *objformat_name = osync_objformat_sink_get_objformat(format_sink); OSyncObjFormat *sourceformat = osync_format_env_find_objformat(formatenv, objformat_name); Modified: trunk/opensync/group/opensync_member.h ============================================================================== --- trunk/opensync/group/opensync_member.h Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/opensync/group/opensync_member.h Sun Mar 29 20:20:04 2009 (r5430) @@ -249,9 +249,12 @@ /** @brief List of all available object formats for a specifc object type of this member * + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. + * * @param member The member pointer * @param objtype The searched object type - * @param error Pointer to a error + * @param error Pointer to an error * @return List of all object formats of a specific object type of the member * */ Modified: trunk/opensync/plugin/opensync_objtype_sink.c ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.c Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/opensync/plugin/opensync_objtype_sink.c Sun Mar 29 20:20:04 2009 (r5430) @@ -209,7 +209,7 @@ OSyncList *osync_objtype_sink_get_objformat_sinks(OSyncObjTypeSink *sink) { osync_assert(sink); - return sink->objformatsinks; + return osync_list_copy(sink->objformatsinks); } void osync_objtype_sink_add_objformat_sink(OSyncObjTypeSink *sink, OSyncObjFormatSink *objformatsink) Modified: trunk/opensync/plugin/opensync_objtype_sink.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink.h Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/opensync/plugin/opensync_objtype_sink.h Sun Mar 29 20:20:04 2009 (r5430) @@ -179,23 +179,16 @@ */ OSYNC_EXPORT void osync_objtype_sink_set_preferred_format(OSyncObjTypeSink *sink, const char *preferred_format); - -/** @brief Returns the number of object formats in the sink - * - * @param sink Pointer to the sink - * @returns the number of object formats in the sink +/** + * @brief Returns a OSyncList that contains the OSyncObjFormatSinks of this objtype sink * - */ -OSYNC_EXPORT unsigned int osync_objtype_sink_num_objformat_sinks(OSyncObjTypeSink *sink); - -/** @brief Returns the nth object format in the sink - * - * @param sink Pointer to the sink - * @param nth the index of the object format to return - * @returns the name of the object format at the specified index + * Please be aware that the returned list has to be freed with + * osync_list_free. If it isn't freed there will be a memory leak. * + * @param sink A pointer to a OSyncObjTypeSink + * @return A shallow copy of the internal list of OSyncObjFormatSinks */ -OSYNC_EXPORT OSyncObjFormatSink *osync_objtype_sink_nth_objformat_sink(OSyncObjTypeSink *sink, unsigned int nth); +OSYNC_EXPORT OSyncList *osync_objtype_sink_get_objformat_sinks(OSyncObjTypeSink *sink); /** @brief Finds the objformat sink for the corresponding objformat * @@ -206,14 +199,6 @@ */ OSYNC_EXPORT OSyncObjFormatSink *osync_objtype_sink_find_objformat_sink(OSyncObjTypeSink *sink, OSyncObjFormat *objformat); -/** @brief Get list of object format sinks - * - * @param sink Pointer to the sink - * @returns List of object format sinks - * - */ -OSYNC_EXPORT OSyncList *osync_objtype_sink_get_objformat_sinks(OSyncObjTypeSink *sink); - /** @brief Adds an object format sink to the sink * * @param sink Pointer to the sink Modified: trunk/opensync/plugin/opensync_objtype_sink_internals.h ============================================================================== --- trunk/opensync/plugin/opensync_objtype_sink_internals.h Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/opensync/plugin/opensync_objtype_sink_internals.h Sun Mar 29 20:20:04 2009 (r5430) @@ -18,8 +18,8 @@ * */ -#ifndef OPENSYNC_OBJTYPE_SINK_INTERNALS_H_ -#define OPENSYNC_OBJTYPE_SINK_INTERNALS_H_ +#ifndef _OPENSYNC_OBJTYPE_SINK_INTERNALS_H_ +#define _OPENSYNC_OBJTYPE_SINK_INTERNALS_H_ /** * @defgroup OSyncObjTypeSinkInternalAPI OpenSync Object Type Sink Internals @@ -306,7 +306,25 @@ */ osync_bool osync_objtype_sink_get_slowsync(OSyncObjTypeSink *sink); +/** @brief Returns the number of object formats in the sink + * + * @param sink Pointer to the sink + * @returns the number of object formats in the sink + * + */ +OSYNC_TEST_EXPORT unsigned int osync_objtype_sink_num_objformat_sinks(OSyncObjTypeSink *sink); + +/** @brief Returns the nth object format in the sink + * + * @param sink Pointer to the sink + * @param nth the index of the object format to return + * @returns the name of the object format at the specified index + * + */ +OSYNC_TEST_EXPORT OSyncObjFormatSink *osync_objtype_sink_nth_objformat_sink(OSyncObjTypeSink *sink, unsigned int nth); + + /*@}*/ -#endif /*OPENSYNC_SINK_INTERNALS_H_*/ +#endif /* _OPENSYNC_SINK_INTERNALS_H_*/ Modified: trunk/tests/client-tests/check_proxy.c ============================================================================== --- trunk/tests/client-tests/check_proxy.c Sun Mar 29 19:48:30 2009 (r5429) +++ trunk/tests/client-tests/check_proxy.c Sun Mar 29 20:20:04 2009 (r5430) @@ -5,6 +5,7 @@ #include <opensync/opensync-plugin.h> #include "opensync/client/opensync_client_proxy_internals.h" +#include "opensync/plugin/opensync_objtype_sink_internals.h" START_TEST (proxy_new) { |