Revision: 14685
Author: adrian.chadd
Date: Thu May 20 22:52:46 2010
Log: Fix vector_shrink() behaviour.


http://code.google.com/p/lusca-cache/source/detail?r=14685

Modified:
 /branches/LUSCA_HEAD/lib/Vector.c

=======================================
--- /branches/LUSCA_HEAD/lib/Vector.c   Thu May 20 03:10:52 2010
+++ /branches/LUSCA_HEAD/lib/Vector.c   Thu May 20 22:52:46 2010
@@ -131,8 +131,25 @@
        return 1;
 }

+/*!
+ * @function
+ *     vector_shrink
+ * @abstract
+ *     Shrink the given vector to the given size.
+ * @discussion
+ *     Any references to the currently-stored data that will be "deleted"
+ *     after shrinking should be removed before calling vector_shrink().
+ *
+ *     The operation is ignored if a larger size than the currently allocated
+ *     count is given.
+ *
+ * @param      v       pointer vector to shrink
+ * @param new_size the new size; must be smaller or equal to the current size
+ */
 void
 vector_shrink(vector_t *v, int new_size)
 {
-       v->used_count = new_size;
-}
+       /* XXX should we have a real debugging assert() in here? */
+       if (new_size < v->used_count)
+               v->used_count = new_size;
+}

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to