fix indenting

This commit is contained in:
Anthony Minessale 2015-09-04 11:25:56 -05:00
parent 3947d443fa
commit ab4514d1e5
8 changed files with 5577 additions and 5489 deletions

View File

@ -461,3 +461,14 @@ const char *mpool_strerror(const int error);
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
#endif /* ! __MPOOL_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -40,7 +40,7 @@ extern "C" {
#endif
/* Be friend of both C90 and C99 compilers */
/* Be friend of both C90 and C99 compilers */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* "inline" and "restrict" are keywords */
#else
@ -49,15 +49,15 @@ extern "C" {
#endif
/**
/**
* Type representing list hashes.
*
* This is a signed integer value.
*/
typedef int32_t list_hash_t;
typedef int32_t list_hash_t;
#ifndef SIMCLIST_NO_DUMPRESTORE
typedef struct {
typedef struct {
uint16_t version; /* dump version */
struct timeval timestamp; /* when the list has been dumped, seconds since UNIX epoch */
uint32_t list_size;
@ -65,10 +65,10 @@ typedef struct {
list_hash_t list_hash; /* hash of the list when dumped, or 0 if invalid */
uint32_t dumpsize;
int consistent; /* 1 if the dump is verified complete/consistent; 0 otherwise */
} list_dump_info_t;
} list_dump_info_t;
#endif
/**
/**
* a comparator of elements.
*
* A comparator of elements is a function that:
@ -77,9 +77,9 @@ typedef struct {
*
* It is responsability of the function to handle possible NULL values.
*/
typedef int (*element_comparator)(const void *a, const void *b);
typedef int (*element_comparator)(const void *a, const void *b);
/**
/**
* a seeker of elements.
*
* An element seeker is a function that:
@ -90,9 +90,9 @@ typedef int (*element_comparator)(const void *a, const void *b);
* It is responsability of the function to handle possible NULL values in any
* argument.
*/
typedef int (*element_seeker)(const void *el, const void *indicator);
typedef int (*element_seeker)(const void *el, const void *indicator);
/**
/**
* an element lenght meter.
*
* An element meter is a function that:
@ -101,9 +101,9 @@ typedef int (*element_seeker)(const void *el, const void *indicator);
*
* It is responsability of the function to handle possible NULL values.
*/
typedef size_t (*element_meter)(const void *el);
typedef size_t (*element_meter)(const void *el);
/**
/**
* a function computing the hash of elements.
*
* An hash computing function is a function that:
@ -112,9 +112,9 @@ typedef size_t (*element_meter)(const void *el);
*
* It is responsability of the function to handle possible NULL values.
*/
typedef list_hash_t (*element_hash_computer)(const void *el);
typedef list_hash_t (*element_hash_computer)(const void *el);
/**
/**
* a function for serializing an element.
*
* A serializer function is one that gets a reference to an element,
@ -132,9 +132,9 @@ typedef list_hash_t (*element_hash_computer)(const void *el);
* @param serialize_buffer reference to fill with the length of the buffer
* @return reference to the buffer with the serialized data
*/
typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict serializ_len);
typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict serializ_len);
/**
/**
* a function for un-serializing an element.
*
* An unserializer function accomplishes the inverse operation of the
@ -149,19 +149,19 @@ typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict
* @param data_len reference to the location where to store the length of the data in the buffer returned
* @return reference to a buffer with the original, unserialized representation of the element
*/
typedef void *(*element_unserializer)(const void *restrict data, uint32_t *restrict data_len);
typedef void *(*element_unserializer)(const void *restrict data, uint32_t *restrict data_len);
/* [private-use] list entry -- olds actual user datum */
struct list_entry_s {
/* [private-use] list entry -- olds actual user datum */
struct list_entry_s {
void *data;
/* doubly-linked list service references */
struct list_entry_s *next;
struct list_entry_s *prev;
};
};
/* [private-use] list attributes */
struct list_attributes_s {
/* [private-use] list attributes */
struct list_attributes_s {
/* user-set routine for comparing list elements */
element_comparator comparator;
/* user-set routing for seeking elements */
@ -175,10 +175,10 @@ struct list_attributes_s {
element_serializer serializer;
/* user-set routine for unserializing an element */
element_unserializer unserializer;
};
};
/** list object */
typedef struct {
/** list object */
typedef struct {
struct list_entry_s *head_sentinel;
struct list_entry_s *tail_sentinel;
struct list_entry_s *mid;
@ -201,17 +201,17 @@ typedef struct {
/* list attributes */
struct list_attributes_s attrs;
} list_t;
} list_t;
/**
/**
* initialize a list object for use.
*
* @param l must point to a user-provided memory location
* @return 0 for success. -1 for failure
*/
int list_init(list_t *restrict l);
int list_init(list_t *restrict l);
/**
/**
* completely remove the list from memory.
*
* This function is the inverse of list_init(). It is meant to be called when
@ -220,9 +220,9 @@ int list_init(list_t *restrict l);
*
* @param l list to destroy
*/
void list_destroy(list_t *restrict l);
void list_destroy(list_t *restrict l);
/**
/**
* set the comparator function for list elements.
*
* Comparator functions are used for searching and sorting. If NULL is passed
@ -234,9 +234,9 @@ void list_destroy(list_t *restrict l);
*
* @see element_comparator()
*/
int list_attributes_comparator(list_t *restrict l, element_comparator comparator_fun);
int list_attributes_comparator(list_t *restrict l, element_comparator comparator_fun);
/**
/**
* set a seeker function for list elements.
*
* Seeker functions are used for finding elements. If NULL is passed as reference
@ -248,9 +248,9 @@ int list_attributes_comparator(list_t *restrict l, element_comparator comparator
*
* @see element_seeker()
*/
int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
/**
/**
* require to free element data when list entry is removed (default: don't free).
*
* [ advanced preference ]
@ -280,9 +280,9 @@ int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
* @see list_meter_double()
* @see list_meter_string()
*/
int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_data);
int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_data);
/**
/**
* set the element hash computing function for the list elements.
*
* [ advanced preference ]
@ -300,9 +300,9 @@ int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_
*
* @see element_hash_computer()
*/
int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash_computer_fun);
int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash_computer_fun);
/**
/**
* set the element serializer function for the list elements.
*
* [ advanced preference ]
@ -321,9 +321,9 @@ int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash
* @see list_dump_filedescriptor()
* @see list_restore_filedescriptor()
*/
int list_attributes_serializer(list_t *restrict l, element_serializer serializer_fun);
int list_attributes_serializer(list_t *restrict l, element_serializer serializer_fun);
/**
/**
* set the element unserializer function for the list elements.
*
* [ advanced preference ]
@ -343,9 +343,9 @@ int list_attributes_serializer(list_t *restrict l, element_serializer serializer
* @see list_dump_filedescriptor()
* @see list_restore_filedescriptor()
*/
int list_attributes_unserializer(list_t *restrict l, element_unserializer unserializer_fun);
int list_attributes_unserializer(list_t *restrict l, element_unserializer unserializer_fun);
/**
/**
* append data at the end of the list.
*
* This function is useful for adding elements with a FIFO/queue policy.
@ -355,9 +355,9 @@ int list_attributes_unserializer(list_t *restrict l, element_unserializer unseri
*
* @return 1 for success. < 0 for failure
*/
int list_append(list_t *restrict l, const void *data);
int list_append(list_t *restrict l, const void *data);
/**
/**
* insert data in the head of the list.
*
* This function is useful for adding elements with a LIFO/Stack policy.
@ -367,9 +367,9 @@ int list_append(list_t *restrict l, const void *data);
*
* @return 1 for success. < 0 for failure
*/
int list_prepend(list_t *restrict l, const void *restrict data);
int list_prepend(list_t *restrict l, const void *restrict data);
/**
/**
* extract the element in the top of the list.
*
* This function is for using a list with a FIFO/queue policy.
@ -377,18 +377,18 @@ int list_prepend(list_t *restrict l, const void *restrict data);
* @param l list to operate
* @return reference to user datum, or NULL on errors
*/
void *list_fetch(list_t *restrict l);
void *list_fetch(list_t *restrict l);
/**
/**
* retrieve an element at a given position.
*
* @param l list to operate
* @param pos [0,size-1] position index of the element wanted
* @return reference to user datum, or NULL on errors
*/
void *list_get_at(const list_t *restrict l, unsigned int pos);
void *list_get_at(const list_t *restrict l, unsigned int pos);
/**
/**
* return the maximum element of the list.
*
* @warning Requires a comparator function to be set for the list.
@ -400,9 +400,9 @@ void *list_get_at(const list_t *restrict l, unsigned int pos);
* @param l list to operate
* @return the reference to the element, or NULL
*/
void *list_get_max(const list_t *restrict l);
void *list_get_max(const list_t *restrict l);
/**
/**
* return the minimum element of the list.
*
* @warning Requires a comparator function to be set for the list.
@ -414,18 +414,18 @@ void *list_get_max(const list_t *restrict l);
* @param l list to operate
* @return the reference to the element, or NULL
*/
void *list_get_min(const list_t *restrict l);
void *list_get_min(const list_t *restrict l);
/**
/**
* retrieve and remove from list an element at a given position.
*
* @param l list to operate
* @param pos [0,size-1] position index of the element wanted
* @return reference to user datum, or NULL on errors
*/
void *list_extract_at(list_t *restrict l, unsigned int pos);
void *list_extract_at(list_t *restrict l, unsigned int pos);
/**
/**
* insert an element at a given position.
*
* @param l list to operate
@ -433,9 +433,9 @@ void *list_extract_at(list_t *restrict l, unsigned int pos);
* @param pos [0,size-1] position index to insert the element at
* @return positive value on success. Negative on failure
*/
int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
/**
/**
* expunge the first found given element from the list.
*
* Inspects the given list looking for the given element; if the element
@ -450,18 +450,18 @@ int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
* @see list_attributes_comparator()
* @see list_delete_at()
*/
int list_delete(list_t *restrict l, const void *data);
int list_delete(list_t *restrict l, const void *data);
/**
/**
* expunge an element at a given position from the list.
*
* @param l list to operate
* @param pos [0,size-1] position index of the element to be deleted
* @return 0 on success. Negative value on failure
*/
int list_delete_at(list_t *restrict l, unsigned int pos);
int list_delete_at(list_t *restrict l, unsigned int pos);
/**
/**
* expunge an array of elements from the list, given their position range.
*
* @param l list to operate
@ -469,9 +469,9 @@ int list_delete_at(list_t *restrict l, unsigned int pos);
* @param posend [posstart,size-1] position of the last element to be deleted
* @return the number of elements successfully removed on success, <0 on error
*/
int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend);
int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend);
/**
/**
* clear all the elements off of the list.
*
* The element datums will not be freed.
@ -482,17 +482,17 @@ int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int po
* @param l list to operate
* @return the number of elements removed on success, <0 on error
*/
int list_clear(list_t *restrict l);
int list_clear(list_t *restrict l);
/**
/**
* inspect the number of elements in the list.
*
* @param l list to operate
* @return number of elements currently held by the list
*/
unsigned int list_size(const list_t *restrict l);
unsigned int list_size(const list_t *restrict l);
/**
/**
* inspect whether the list is empty.
*
* @param l list to operate
@ -500,9 +500,9 @@ unsigned int list_size(const list_t *restrict l);
*
* @see list_size()
*/
int list_empty(const list_t *restrict l);
int list_empty(const list_t *restrict l);
/**
/**
* find the position of an element in a list.
*
* @warning Requires a comparator function to be set for the list.
@ -519,9 +519,9 @@ int list_empty(const list_t *restrict l);
* @see list_attributes_comparator()
* @see list_get_at()
*/
int list_locate(const list_t *restrict l, const void *data);
int list_locate(const list_t *restrict l, const void *data);
/**
/**
* returns an element given an indicator.
*
* @warning Requires a seeker function to be set for the list.
@ -534,9 +534,9 @@ int list_locate(const list_t *restrict l, const void *data);
* @param indicator indicator data to pass to the seeker along with elements
* @return reference to the element accepted by the seeker, or NULL if none found
*/
void *list_seek(list_t *restrict l, const void *indicator);
void *list_seek(list_t *restrict l, const void *indicator);
/**
/**
* inspect whether some data is member of the list.
*
* @warning Requires a comparator function to be set for the list.
@ -555,9 +555,9 @@ void *list_seek(list_t *restrict l, const void *indicator);
*
* @see list_attributes_comparator()
*/
int list_contains(const list_t *restrict l, const void *data);
int list_contains(const list_t *restrict l, const void *data);
/**
/**
* concatenate two lists
*
* Concatenates one list with another, and stores the result into a
@ -574,9 +574,9 @@ int list_contains(const list_t *restrict l, const void *data);
* @param dest reference to the destination list
* @return 0 for success, -1 for errors
*/
int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
/**
/**
* sort list elements.
*
* @warning Requires a comparator function to be set for the list.
@ -591,9 +591,9 @@ int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
*
* @see list_attributes_comparator()
*/
int list_sort(list_t *restrict l, int versus);
int list_sort(list_t *restrict l, int versus);
/**
/**
* start an iteration session.
*
* This function prepares the list to be iterated.
@ -603,33 +603,33 @@ int list_sort(list_t *restrict l, int versus);
*
* @see list_iterator_stop()
*/
int list_iterator_start(list_t *restrict l);
int list_iterator_start(list_t *restrict l);
/**
/**
* return the next element in the iteration session.
*
* @param l list to operate
* @return element datum, or NULL on errors
*/
void *list_iterator_next(list_t *restrict l);
void *list_iterator_next(list_t *restrict l);
/**
/**
* inspect whether more elements are available in the iteration session.
*
* @param l list to operate
* @return 0 iff no more elements are available.
*/
int list_iterator_hasnext(const list_t *restrict l);
int list_iterator_hasnext(const list_t *restrict l);
/**
/**
* end an iteration session.
*
* @param l list to operate
* @return 0 iff the iteration session cannot be stopped
*/
int list_iterator_stop(list_t *restrict l);
int list_iterator_stop(list_t *restrict l);
/**
/**
* return the hash of the current status of the list.
*
* @param l list to operate
@ -637,10 +637,10 @@ int list_iterator_stop(list_t *restrict l);
*
* @return 0 for success; <0 for failure
*/
int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
#ifndef SIMCLIST_NO_DUMPRESTORE
/**
/**
* get meta informations on a list dump on filedescriptor.
*
* [ advanced function ]
@ -655,9 +655,9 @@ int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
*
* @see list_dump_filedescriptor()
*/
int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
/**
/**
* get meta informations on a list dump on file.
*
* [ advanced function ]
@ -670,9 +670,9 @@ int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
*
* @see list_dump_filedescriptor()
*/
int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *restrict info);
int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *restrict info);
/**
/**
* dump the list into an open, writable file descriptor.
*
* This function "dumps" the list to a persistent storage so it can be
@ -706,9 +706,9 @@ int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *rest
* @see list_attributes_copy()
* @see list_attributes_serializer()
*/
int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict len);
int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict len);
/**
/**
* dump the list to a file name.
*
* This function creates a filename and dumps the current content of the list
@ -729,9 +729,9 @@ int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict
*
* This function stores a representation of the list
*/
int list_dump_file(const list_t *restrict l, const char *restrict filename, size_t *restrict len);
int list_dump_file(const list_t *restrict l, const char *restrict filename, size_t *restrict len);
/**
/**
* restore the list from an open, readable file descriptor to memory.
*
* This function is the "inverse" of list_dump_filedescriptor(). It restores
@ -749,9 +749,9 @@ int list_dump_file(const list_t *restrict l, const char *restrict filename, size
* @param len location to store the length of the dump read (bytes), or NULL
* @return 0 if successful; -1 otherwise
*/
int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len);
int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len);
/**
/**
* restore the list from a file name.
*
* This function restores the content of a list from a file into memory. It is
@ -767,210 +767,210 @@ int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len
* @param len location to store the length of the dump read (bytes), or NULL
* @return 0 if successful; -1 otherwise
*/
int list_restore_file(list_t *restrict l, const char *restrict filename, size_t *len);
int list_restore_file(list_t *restrict l, const char *restrict filename, size_t *len);
#endif
/* ready-made comparators, meters and hash computers */
/* ready-made comparators, meters and hash computers */
/* comparator functions */
/**
/**
* ready-made comparator for int8_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int8_t(const void *a, const void *b);
int list_comparator_int8_t(const void *a, const void *b);
/**
/**
* ready-made comparator for int16_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int16_t(const void *a, const void *b);
int list_comparator_int16_t(const void *a, const void *b);
/**
/**
* ready-made comparator for int32_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int32_t(const void *a, const void *b);
int list_comparator_int32_t(const void *a, const void *b);
/**
/**
* ready-made comparator for int64_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_int64_t(const void *a, const void *b);
int list_comparator_int64_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint8_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint8_t(const void *a, const void *b);
int list_comparator_uint8_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint16_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint16_t(const void *a, const void *b);
int list_comparator_uint16_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint32_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint32_t(const void *a, const void *b);
int list_comparator_uint32_t(const void *a, const void *b);
/**
/**
* ready-made comparator for uint64_t elements.
* @see list_attributes_comparator()
*/
int list_comparator_uint64_t(const void *a, const void *b);
int list_comparator_uint64_t(const void *a, const void *b);
/**
/**
* ready-made comparator for float elements.
* @see list_attributes_comparator()
*/
int list_comparator_float(const void *a, const void *b);
int list_comparator_float(const void *a, const void *b);
/**
/**
* ready-made comparator for double elements.
* @see list_attributes_comparator()
*/
int list_comparator_double(const void *a, const void *b);
int list_comparator_double(const void *a, const void *b);
/**
/**
* ready-made comparator for string elements.
* @see list_attributes_comparator()
*/
int list_comparator_string(const void *a, const void *b);
int list_comparator_string(const void *a, const void *b);
/* metric functions */
/**
/**
* ready-made metric function for int8_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int8_t(const void *el);
size_t list_meter_int8_t(const void *el);
/**
/**
* ready-made metric function for int16_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int16_t(const void *el);
size_t list_meter_int16_t(const void *el);
/**
/**
* ready-made metric function for int32_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int32_t(const void *el);
size_t list_meter_int32_t(const void *el);
/**
/**
* ready-made metric function for int64_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_int64_t(const void *el);
size_t list_meter_int64_t(const void *el);
/**
/**
* ready-made metric function for uint8_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint8_t(const void *el);
size_t list_meter_uint8_t(const void *el);
/**
/**
* ready-made metric function for uint16_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint16_t(const void *el);
size_t list_meter_uint16_t(const void *el);
/**
/**
* ready-made metric function for uint32_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint32_t(const void *el);
size_t list_meter_uint32_t(const void *el);
/**
/**
* ready-made metric function for uint64_t elements.
* @see list_attributes_copy()
*/
size_t list_meter_uint64_t(const void *el);
size_t list_meter_uint64_t(const void *el);
/**
/**
* ready-made metric function for float elements.
* @see list_attributes_copy()
*/
size_t list_meter_float(const void *el);
size_t list_meter_float(const void *el);
/**
/**
* ready-made metric function for double elements.
* @see list_attributes_copy()
*/
size_t list_meter_double(const void *el);
size_t list_meter_double(const void *el);
/**
/**
* ready-made metric function for string elements.
* @see list_attributes_copy()
*/
size_t list_meter_string(const void *el);
size_t list_meter_string(const void *el);
/* hash functions */
/**
/**
* ready-made hash function for int8_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int8_t(const void *el);
list_hash_t list_hashcomputer_int8_t(const void *el);
/**
/**
* ready-made hash function for int16_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int16_t(const void *el);
list_hash_t list_hashcomputer_int16_t(const void *el);
/**
/**
* ready-made hash function for int32_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int32_t(const void *el);
list_hash_t list_hashcomputer_int32_t(const void *el);
/**
/**
* ready-made hash function for int64_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_int64_t(const void *el);
list_hash_t list_hashcomputer_int64_t(const void *el);
/**
/**
* ready-made hash function for uint8_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint8_t(const void *el);
list_hash_t list_hashcomputer_uint8_t(const void *el);
/**
/**
* ready-made hash function for uint16_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint16_t(const void *el);
list_hash_t list_hashcomputer_uint16_t(const void *el);
/**
/**
* ready-made hash function for uint32_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint32_t(const void *el);
list_hash_t list_hashcomputer_uint32_t(const void *el);
/**
/**
* ready-made hash function for uint64_t elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_uint64_t(const void *el);
list_hash_t list_hashcomputer_uint64_t(const void *el);
/**
/**
* ready-made hash function for float elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_float(const void *el);
list_hash_t list_hashcomputer_float(const void *el);
/**
/**
* ready-made hash function for double elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_double(const void *el);
list_hash_t list_hashcomputer_double(const void *el);
/**
/**
* ready-made hash function for string elements.
* @see list_attributes_hash_computer()
*/
list_hash_t list_hashcomputer_string(const void *el);
list_hash_t list_hashcomputer_string(const void *el);
#ifdef __cplusplus
}
@ -978,3 +978,13 @@ list_hash_t list_hashcomputer_string(const void *el);
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -28,7 +28,7 @@
extern "C" {
#endif /* __cplusplus */
/*
/*
* To build a "key" in any of the below routines, pass in a pointer to
* the key and its size [i.e. sizeof(int), etc]. With any of the
* "key" or "data" arguments, if their size is < 0, it will do an
@ -40,7 +40,7 @@ extern "C" {
* deleting from firstkey to NULL it will work fine.
*/
/* return types for table functions */
/* return types for table functions */
#define TABLE_ERROR_NONE 1 /* no error from function */
#define TABLE_ERROR_PNT 2 /* bad table pointer */
#define TABLE_ERROR_ARG_NULL 3 /* buffer args were null */
@ -62,11 +62,11 @@ extern "C" {
#define TABLE_ERROR_COMPARE 19 /* problems with internal comparison */
#define TABLE_ERROR_FREE 20 /* memory free error */
/*
/*
* Table flags set with table_attr.
*/
/*
/*
* Automatically adjust the number of table buckets on the fly.
* Whenever the number of entries gets above some threshold, the
* number of buckets is realloced to a new size and each entry is
@ -75,20 +75,20 @@ extern "C" {
*/
#define TABLE_FLAG_AUTO_ADJUST (1<<0)
/*
/*
* If the above auto-adjust flag is set, also adjust the number of
* table buckets down as we delete entries.
*/
#define TABLE_FLAG_ADJUST_DOWN (1<<1)
/* structure to walk through the fields in a linear order */
typedef struct {
/* structure to walk through the fields in a linear order */
typedef struct {
unsigned int tl_magic; /* magic structure to ensure correct init */
unsigned int tl_bucket_c; /* where in the table buck array we are */
unsigned int tl_entry_c; /* in the bucket, which entry we are on */
} table_linear_t;
} table_linear_t;
/*
/*
* int (*table_compare_t)
*
* DESCRIPTION
@ -118,12 +118,12 @@ typedef struct {
*
* data2_size - Pointer to the size of the second data entry.
*/
typedef int (*table_compare_t)(const void *key1, const int key1_size,
typedef int (*table_compare_t)(const void *key1, const int key1_size,
const void *data1, const int data1_size,
const void *key2, const int key2_size,
const void *data2, const int data2_size);
/*
/*
* int (*table_mem_alloc_t)
*
* DESCRIPTION
@ -143,9 +143,9 @@ typedef int (*table_compare_t)(const void *key1, const int key1_size,
*
* size -> Number of bytes that needs to be allocated.
*/
typedef void *(*table_mem_alloc_t)(void *pool_p, const unsigned long size);
typedef void *(*table_mem_alloc_t)(void *pool_p, const unsigned long size);
/*
/*
* int (*table_mem_resize_t)
*
* DESCRIPTION
@ -173,11 +173,11 @@ typedef void *(*table_mem_alloc_t)(void *pool_p, const unsigned long size);
*
* new_size -> New size of the allocation.
*/
typedef void *(*table_mem_resize_t)(void *pool_p, void *old_addr,
typedef void *(*table_mem_resize_t)(void *pool_p, void *old_addr,
const unsigned long old_size,
const unsigned long new_size);
/*
/*
* int (*table_mem_free_t)
*
* DESCRIPTION
@ -200,7 +200,7 @@ typedef void *(*table_mem_resize_t)(void *pool_p, void *old_addr,
* min_size -> Minimum size of the address being freed or 0 if not
* known. This can also be the exact size if known.
*/
typedef int (*table_mem_free_t)(void *pool_p, void *addr,
typedef int (*table_mem_free_t)(void *pool_p, void *addr,
const unsigned long min_size);
#ifdef TABLE_MAIN
@ -209,17 +209,17 @@ typedef int (*table_mem_free_t)(void *pool_p, void *addr,
#else
/* generic table type */
typedef void table_t;
/* generic table type */
typedef void table_t;
/* generic table entry type */
typedef void table_entry_t;
/* generic table entry type */
typedef void table_entry_t;
#endif
/*<<<<<<<<<< The below prototypes are auto-generated by fillproto */
/*<<<<<<<<<< The below prototypes are auto-generated by fillproto */
/*
/*
* table_t *table_alloc
*
* DESCRIPTION:
@ -240,10 +240,10 @@ typedef void table_entry_t;
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_alloc(const unsigned int bucket_n, int *error_p);
extern
table_t *table_alloc(const unsigned int bucket_n, int *error_p);
/*
/*
* table_t *table_alloc_in_pool
*
* DESCRIPTION:
@ -275,14 +275,14 @@ table_t *table_alloc(const unsigned int bucket_n, int *error_p);
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_alloc_in_pool(const unsigned int bucket_n,
extern
table_t *table_alloc_in_pool(const unsigned int bucket_n,
void *mem_pool,
table_mem_alloc_t alloc_func,
table_mem_resize_t resize_func,
table_mem_free_t free_func, int *error_p);
/*
/*
* int table_attr
*
* DESCRIPTION:
@ -302,10 +302,10 @@ table_t *table_alloc_in_pool(const unsigned int bucket_n,
*
* attr - Attribute(s) that we will be applying to the table.
*/
extern
int table_attr(table_t *table_p, const int attr);
extern
int table_attr(table_t *table_p, const int attr);
/*
/*
* int table_set_data_alignment
*
* DESCRIPTION:
@ -342,10 +342,10 @@ int table_attr(table_t *table_p, const int attr);
* alignment - Alignment requested for the data. Must be a power of
* 2. Set to 0 for none.
*/
extern
int table_set_data_alignment(table_t *table_p, const int alignment);
extern
int table_set_data_alignment(table_t *table_p, const int alignment);
/*
/*
* int table_clear
*
* DESCRIPTION:
@ -362,10 +362,10 @@ int table_set_data_alignment(table_t *table_p, const int alignment);
*
* table_p - Table structure pointer that we will be clearing.
*/
extern
int table_clear(table_t *table_p);
extern
int table_clear(table_t *table_p);
/*
/*
* int table_free
*
* DESCRIPTION:
@ -382,10 +382,10 @@ int table_clear(table_t *table_p);
*
* table_p - Table structure pointer that we will be freeing.
*/
extern
int table_free(table_t *table_p);
extern
int table_free(table_t *table_p);
/*
/*
* int table_insert_kd
*
* DESCRIPTION:
@ -461,14 +461,14 @@ int table_free(table_t *table_p);
* the data in the table with the new data if the key already exists
* in the table.
*/
extern
int table_insert_kd(table_t *table_p,
extern
int table_insert_kd(table_t *table_p,
const void *key_buf, const int key_size,
const void *data_buf, const int data_size,
void **key_buf_p, void **data_buf_p,
const char overwrite_b);
/*
/*
* int table_insert
*
* DESCRIPTION:
@ -520,13 +520,13 @@ int table_insert_kd(table_t *table_p,
* the data in the table with the new data if the key already exists
* in the table.
*/
extern
int table_insert(table_t *table_p,
extern
int table_insert(table_t *table_p,
const void *key_buf, const int key_size,
const void *data_buf, const int data_size,
void **data_buf_p, const char overwrite_b);
/*
/*
* int table_retrieve
*
* DESCRIPTION:
@ -565,12 +565,12 @@ int table_insert(table_t *table_p,
* to the size of the data stored in the table that is associated with
* the key.
*/
extern
int table_retrieve(table_t *table_p,
extern
int table_retrieve(table_t *table_p,
const void *key_buf, const int key_size,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_delete
*
* DESCRIPTION:
@ -615,12 +615,12 @@ int table_retrieve(table_t *table_p,
* to the size of the data that was stored in the table and that was
* associated with the key.
*/
extern
int table_delete(table_t *table_p,
extern
int table_delete(table_t *table_p,
const void *key_buf, const int key_size,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_delete_first
*
* DESCRIPTION:
@ -669,12 +669,12 @@ int table_delete(table_t *table_p,
* to the size of the data that was stored in the table and that was
* associated with the key.
*/
extern
int table_delete_first(table_t *table_p,
extern
int table_delete_first(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_info
*
* DESCRIPTION:
@ -698,10 +698,10 @@ int table_delete_first(table_t *table_p,
* num_entries_p - Pointer to an integer which, if not NULL, will
* contain the number of entries stored in the table.
*/
extern
int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p);
extern
int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p);
/*
/*
* int table_adjust
*
* DESCRIPTION:
@ -721,10 +721,10 @@ int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p);
* bucket_n - Number buckets to adjust the table to. Set to 0 to
* adjust the table to its number of entries.
*/
extern
int table_adjust(table_t *table_p, const int bucket_n);
extern
int table_adjust(table_t *table_p, const int bucket_n);
/*
/*
* int table_type_size
*
* DESCRIPTION:
@ -739,10 +739,10 @@ int table_adjust(table_t *table_p, const int bucket_n);
*
* None.
*/
extern
int table_type_size(void);
extern
int table_type_size(void);
/*
/*
* int table_first
*
* DESCRIPTION:
@ -785,12 +785,12 @@ int table_type_size(void);
* to the size of the data that is stored in the table and that is
* associated with the first key.
*/
extern
int table_first(table_t *table_p,
extern
int table_first(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_next
*
* DESCRIPTION:
@ -833,12 +833,12 @@ int table_first(table_t *table_p,
* to the size of the data that is stored in the table and that is
* associated with the next key.
*/
extern
int table_next(table_t *table_p,
extern
int table_next(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_this
*
* DESCRIPTION:
@ -880,12 +880,12 @@ int table_next(table_t *table_p,
* to the size of the data that is stored in the table and that is
* associated with the current key.
*/
extern
int table_this(table_t *table_p,
extern
int table_this(table_t *table_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_first_r
*
* DESCRIPTION:
@ -929,12 +929,12 @@ int table_this(table_t *table_p,
* to the size of the data that is stored in the table and that is
* associated with the first key.
*/
extern
int table_first_r(table_t *table_p, table_linear_t *linear_p,
extern
int table_first_r(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_next_r
*
* DESCRIPTION:
@ -978,12 +978,12 @@ int table_first_r(table_t *table_p, table_linear_t *linear_p,
* to the size of the data that is stored in the table and that is
* associated with the next key.
*/
extern
int table_next_r(table_t *table_p, table_linear_t *linear_p,
extern
int table_next_r(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* int table_this_r
*
* DESCRIPTION:
@ -1027,12 +1027,12 @@ int table_next_r(table_t *table_p, table_linear_t *linear_p,
* to the size of the data that is stored in the table and that is
* associated with the current key.
*/
extern
int table_this_r(table_t *table_p, table_linear_t *linear_p,
extern
int table_this_r(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* table_t *table_mmap
*
* DESCRIPTION:
@ -1052,10 +1052,10 @@ int table_this_r(table_t *table_p, table_linear_t *linear_p,
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_mmap(const char *path, int *error_p);
extern
table_t *table_mmap(const char *path, int *error_p);
/*
/*
* int table_munmap
*
* DESCRIPTION:
@ -1070,10 +1070,10 @@ table_t *table_mmap(const char *path, int *error_p);
*
* table_p - Mmaped table pointer to unmap.
*/
extern
int table_munmap(table_t *table_p);
extern
int table_munmap(table_t *table_p);
/*
/*
* int table_read
*
* DESCRIPTION:
@ -1095,10 +1095,10 @@ int table_munmap(table_t *table_p);
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_t *table_read(const char *path, int *error_p);
extern
table_t *table_read(const char *path, int *error_p);
/*
/*
* int table_write
*
* DESCRIPTION:
@ -1120,10 +1120,10 @@ table_t *table_read(const char *path, int *error_p);
* mode - Mode of the file. This argument is passed on to open when
* the file is created.
*/
extern
int table_write(const table_t *table_p, const char *path, const int mode);
extern
int table_write(const table_t *table_p, const char *path, const int mode);
/*
/*
* table_entry_t *table_order
*
* DESCRIPTION:
@ -1157,11 +1157,11 @@ int table_write(const table_t *table_p, const char *path, const int mode);
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_entry_t **table_order(table_t *table_p, table_compare_t compare,
extern
table_entry_t **table_order(table_t *table_p, table_compare_t compare,
int *num_entries_p, int *error_p);
/*
/*
* int table_order_free
*
* DESCRIPTION:
@ -1185,11 +1185,11 @@ table_entry_t **table_order(table_t *table_p, table_compare_t compare,
* entry_n - Number of entries in the array as passed back by
* table_order or table_order_pos in num_entries_p.
*/
extern
int table_order_free(table_t *table_p, table_entry_t **table_entries,
extern
int table_order_free(table_t *table_p, table_entry_t **table_entries,
const int entry_n);
/*
/*
* int table_entry
*
* DESCRIPTION:
@ -1228,12 +1228,12 @@ int table_order_free(table_t *table_p, table_entry_t **table_entries,
* data_size_p - Pointer to an integer which, if not NULL, will be set
* to the size of the data that is stored in the table.
*/
extern
int table_entry(table_t *table_p, table_entry_t *entry_p,
extern
int table_entry(table_t *table_p, table_entry_t *entry_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* table_linear_t *table_order_pos
*
* DESCRIPTION:
@ -1267,11 +1267,11 @@ int table_entry(table_t *table_p, table_entry_t *entry_p,
* error_p - Pointer to an integer which, if not NULL, will contain a
* table error code.
*/
extern
table_linear_t *table_order_pos(table_t *table_p, table_compare_t compare,
extern
table_linear_t *table_order_pos(table_t *table_p, table_compare_t compare,
int *num_entries_p, int *error_p);
/*
/*
* int table_order_pos_free
*
* DESCRIPTION:
@ -1295,11 +1295,11 @@ table_linear_t *table_order_pos(table_t *table_p, table_compare_t compare,
* entry_n - Number of entries in the array as passed back by
* table_order or table_order_pos in num_entries_p.
*/
extern
int table_order_pos_free(table_t *table_p, table_linear_t *table_entries,
extern
int table_order_pos_free(table_t *table_p, table_linear_t *table_entries,
const int entry_n);
/*
/*
* int table_entry_pos
*
* DESCRIPTION:
@ -1338,12 +1338,12 @@ int table_order_pos_free(table_t *table_p, table_linear_t *table_entries,
* data_size_p - Pointer to an integer which, if not NULL, will be set
* to the size of the data that is stored in the table.
*/
extern
int table_entry_pos(table_t *table_p, table_linear_t *linear_p,
extern
int table_entry_pos(table_t *table_p, table_linear_t *linear_p,
void **key_buf_p, int *key_size_p,
void **data_buf_p, int *data_size_p);
/*
/*
* const char *table_strerror
*
* DESCRIPTION:
@ -1360,13 +1360,24 @@ int table_entry_pos(table_t *table_p, table_linear_t *linear_p,
*
* error - Error number that we are converting.
*/
extern
const char *table_strerror(const int error);
extern
const char *table_strerror(const int error);
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
/*<<<<<<<<<< This is end of the auto-generated output from fillproto. */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ! __TABLE_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -227,3 +227,15 @@ static error_str_t errors[] = {
#define INVALID_ERROR "invalid error code"
#endif /* ! __TABLE_LOC_H__ */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -1766,3 +1766,15 @@ const char *mpool_strerror(const int error)
return "invalid error code";
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -26,12 +26,12 @@
#include <errno.h> /* for setting errno */
#include <sys/types.h>
#ifndef _WIN32
/* not in Windows! */
/* not in Windows! */
# include <unistd.h>
# include <stdint.h>
#endif
#ifndef SIMCLIST_NO_DUMPRESTORE
/* includes for dump/restore */
/* includes for dump/restore */
# include <time.h>
# include <sys/uio.h> /* for READ_ERRCHECK() and write() */
# include <fcntl.h> /* for open() etc */
@ -100,7 +100,7 @@ typedef INT64 int64_t;
} while (0);
/* convert 64bit integers from host to network format */
#define hton64(x) (\
#define hton64(x) ( \
htons(1) == 1 ? \
(uint64_t)x /* big endian */ \
: /* little endian */ \
@ -1523,3 +1523,13 @@ static int list_attrOk(const list_t *restrict l) {
#endif
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -627,7 +627,7 @@ static int external_compare(const void *p1, const void *p2,
*
* err_bp - Pointer to an integer which will be set with 1 if an error
* has occurred. It cannot be NULL.
*/
*/
static int external_compare_pos(const void *p1, const void *p2,
table_compare_t user_compare,
const table_t *table_p, int *err_bp)
@ -4077,3 +4077,14 @@ const char *table_strerror(const int error)
return INVALID_ERROR;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/

View File

@ -293,3 +293,14 @@ int main(int argc, char **argv)
exit(0);
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/