[Opensrf-commits] r1870 - in trunk: include/opensrf src/libopensrf (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Dec 10 01:21:45 EST 2009
Author: scottmk
Date: 2009-12-10 01:21:41 -0500 (Thu, 10 Dec 2009)
New Revision: 1870
Modified:
trunk/include/opensrf/osrf_list.h
trunk/src/libopensrf/osrf_list.c
trunk/src/libopensrf/string_array.c
Log:
Add three new functions:
osrfListSwap() -- swaps the contents of two osrfLists
osrfStringArrayClear() -- renders an osrfStringArray empty
osrfStringArraySwap() -- swaps the contents of two osrfStringArrays
M include/opensrf/osrf_list.h
M src/libopensrf/string_array.c
M src/libopensrf/osrf_list.c
Modified: trunk/include/opensrf/osrf_list.h
===================================================================
--- trunk/include/opensrf/osrf_list.h 2009-12-10 05:09:53 UTC (rev 1869)
+++ trunk/include/opensrf/osrf_list.h 2009-12-10 06:21:41 UTC (rev 1870)
@@ -90,6 +90,8 @@
void osrfListClear( osrfList* list );
+void osrfListSwap( osrfList* one, osrfList* two );
+
void* osrfListRemove( osrfList* list, unsigned int position );
void* osrfListExtract( osrfList* list, unsigned int position );
Modified: trunk/src/libopensrf/osrf_list.c
===================================================================
--- trunk/src/libopensrf/osrf_list.c 2009-12-10 05:09:53 UTC (rev 1869)
+++ trunk/src/libopensrf/osrf_list.c 2009-12-10 06:21:41 UTC (rev 1870)
@@ -191,6 +191,25 @@
}
/**
+ @brief Exchange the contents of two osrfLists.
+ @param one Pointer to the first osrfList.
+ @param two Pointer to the second osrfList.
+
+ After the call, the first list contains what had been the contents of the second,
+ and vice versa. This swap also works if the two parameters point to the same
+ list; i.e. there is no net effect.
+
+ If either parameter is NULL, nothing happens.
+*/
+void osrfListSwap( osrfList* one, osrfList* two ) {
+ if( one && two ) {
+ osrfList temp = *one;
+ *one = *two;
+ *two = temp;
+ }
+}
+
+/**
@brief Remove the pointer from a specified position.
@param list A pointer to the osrfList.
@param position A zero-based index identifying the pointer to be removed.
Modified: trunk/src/libopensrf/string_array.c
===================================================================
--- trunk/src/libopensrf/string_array.c 2009-12-10 05:09:53 UTC (rev 1869)
+++ trunk/src/libopensrf/string_array.c 2009-12-10 06:21:41 UTC (rev 1870)
@@ -79,6 +79,37 @@
}
/**
+ @brief Render an osrfStringArray empty.
+ @param arr Pointer to the osrfStringArray to be emptied.
+*/
+void osrfStringArrayClear( osrfStringArray* arr ) {
+ if( arr ) {
+ osrfListClear( &arr->list );
+ arr->size = 0;
+ }
+}
+
+/**
+ @brief Exchange the contents of two osrfStringArrays.
+ @param one Pointer to the first osrfStringArray.
+ @param two Pointer to the second osrfStringArray.
+
+ After the swap, the first osrfStringArray contains what had been the contents of the
+ second, and vice versa. The swap also works if both parameters point to the same
+ osrfStringArray; i.e. there is no net change.
+
+ If either parameter is NULL, nothing happens.
+*/
+void osrfStringArraySwap( osrfStringArray* one, osrfStringArray* two ) {
+ if( one && two ) {
+ osrfListSwap( &one->list, &two->list );
+ int temp = one->size;
+ one->size = two->size;
+ two->size = temp;
+ }
+}
+
+/**
@brief Free an osrfStringArray, and all the strings inside it.
@param arr Pointer to the osrfStringArray to be freed.
*/
More information about the opensrf-commits
mailing list