diff options
author | Chris Hall (GMCH) <chris.hall@highwayman.com> | 2009-11-24 19:54:30 +0000 |
---|---|---|
committer | Chris Hall (GMCH) <chris.hall@highwayman.com> | 2009-11-24 19:54:30 +0000 |
commit | 5d41cec800dc6100b8181b95a08f7803dac6eeb9 (patch) | |
tree | 963aab0f9ce07c91a3a47c5bcb866ed3b2a163c3 /lib/memory.h | |
parent | 9964fcfc2282c8f3468b3b7355c5dea3089f0f14 (diff) | |
download | quagga-5d41cec800dc6100b8181b95a08f7803dac6eeb9.tar.bz2 quagga-5d41cec800dc6100b8181b95a08f7803dac6eeb9.tar.xz |
Upgrade lib/vector.c & .h
This upgrade maintains the existing vector operations, but changes the
underlying mechanisms. It then adds a number of new functions,
extending the operations on vectors.
The "struct vector" is redefined, which affects only some code in
lib/command.c -- which pokes around inside what should be treated as a
private data structure. Pro tem this is supported by a macro.
The constant VECTOR_MIN_SIZE has been removed -- if there is a minimum
size that should be enforced by the vector code.
New functions include:
vector_insert_item -- insert item, moving existing items
vector_move_item -- move item from place to place in vector
vector_delete_item -- delete item and close up gap
vector_reverse -- reverse order of vector
vector_push_item -- simple push
vector_pop_item -- simple pop
vector_insert -- insert 1 or more NULL items, moving
existing items
vector_delete -- delete 1 or more items and close up gap
vector_bsearch -- perform binary search on vector
vector_sort -- qsort vector
vector_copy_here -- make copy of body of vector
vector_move_here -- move body of vector
vector_copy_append -- append copy of vector to end of another
vector_move_append -- move body of vector to the end of another
vector_copy_extract -- copy part of one vector to another
vector_move_extract -- move part of one vector to another
vector_copy_splice -- copy part of one vector to replace part of
another, taking a copy of the replaced part
vector_move_splice -- move part of one vector to replace part of
another, taking a copy of the replaced part
vector_copy_replace -- copy part of one vector to replace part of
another
vector_move_replace -- move part of one vector to replace part of
another
vector_discard -- discard body of vector
vector_chop -- discard any unused memory in body of vector
vector_decant -- decant vector to new body
Other files affected:
command.c:
-- removal of VECTOR_MIN_SIZE
-- use of vector_sort()
-- use of VECTOR_INDEX to poke around inside vector
(removing this is TODO)
memtypes.c & memory.c
-- updating names and comments for vectors
vty.c
-- removal of VECTOR_MIN_SIZE
memory.h
-- added SIZE(t,n) macro -- (sizeof(t) * (n))
Diffstat (limited to 'lib/memory.h')
-rw-r--r-- | lib/memory.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/memory.h b/lib/memory.h index 42eb5cae..037efef2 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -32,7 +32,7 @@ struct mlist { struct memory_list *list; const char *name; }; - + #include "lib/memtypes.h" extern struct mlist mlists[]; @@ -60,6 +60,8 @@ extern struct mlist mlists[]; #define XSTRDUP(mtype, str) zstrdup ((mtype), (str)) #endif /* MEMORY_LOG */ +#define SIZE(t,n) (sizeof(t) * (n)) + /* Prototypes of memory function. */ extern void *zmalloc (int type, size_t size); extern void *zcalloc (int type, size_t size); @@ -69,7 +71,7 @@ extern char *zstrdup (int type, const char *str); extern void *mtype_zmalloc (const char *file, int line, int type, size_t size); -extern void *mtype_zcalloc (const char *file, int line, int type, +extern void *mtype_zcalloc (const char *file, int line, int type, size_t num, size_t size); extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr, |