Revision: 14302
Author: adrian.chadd
Date: Tue Sep 15 22:10:50 2009
Log: From playpen/LUSCA_HEAD_http_vector - implement some new vector  
operations



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

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

=======================================
--- /branches/LUSCA_HEAD/include/Vector.h       Wed Jul 22 07:37:20 2009
+++ /branches/LUSCA_HEAD/include/Vector.h       Tue Sep 15 22:10:50 2009
@@ -8,6 +8,7 @@
        void *data;
  };
  typedef struct _vector_t vector_t;
+typedef struct _vector_t Vector;

  void vector_init(vector_t *v, int obj_size, int obj_count);
  void vector_done(vector_t *v);
@@ -15,6 +16,8 @@
  static inline void * vector_get(const vector_t *v, int offset) { return  
((char *) v->data + (v->obj_size * offset)); }
  void * vector_append(vector_t *v);
  void * vector_insert(vector_t *v, int position);
+int vector_copy_item(vector_t *v, int dst, int src);
+void vector_shrink(vector_t *v, int new_size);

  #define       vector_numentries(v)    ( (v)->used_count )
  #define       vector_size(v)          ( (v)->alloc_count )
=======================================
--- /branches/LUSCA_HEAD/lib/Vector.c   Wed Jul 22 07:37:20 2009
+++ /branches/LUSCA_HEAD/lib/Vector.c   Tue Sep 15 22:10:50 2009
@@ -93,3 +93,22 @@
        v->used_count++;
        return ((char *) v->data + (v->obj_size * position));
  }
+
+int
+vector_copy_item(vector_t *v, int dst, int src)
+{
+       if (dst >= v->used_count)
+               return -1;
+       if (src >= v->used_count)
+               return -1;
+       memcpy( (char *) v->data + (dst) * v->obj_size,
+               (char *) v->data + (src) * v->obj_size,
+               v->obj_size );
+       return 1;
+}
+
+void
+vector_shrink(vector_t *v, int new_size)
+{
+       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