Sat Sep 22 23:04:50 EDT 2001
2 libmbaThe mba library consists of general functionality common to potentially any application. 2.1 stackA dynamically resizing stack. |
struct stack; struct stack *stack_new(unsigned int max_size); void stack_del(struct stack *s, void (*free_data_fn)(void *)); void stack_clear(struct stack *s, void (*free_data_fn)(void *)); int stack_push(struct stack *s, void *data); void *stack_pop(struct stack *s); int stack_is_empty(const struct stack *s); unsigned int stack_size(const struct stack *s); void stack_iterate(struct stack *s); void *stack_next(struct stack *s); void *stack_peek(struct stack *s); |
2.2 linkedlistA singularly linked list. |
struct linkedlist; struct linkedlist *linkedlist_new(unsigned int); void linkedlist_del(struct linkedlist *l, void (*free_data_fn)(void *)); void linkedlist_clear(struct linkedlist *l, void (*free_data_fn)(void *)); int linkedlist_add(struct linkedlist *l, void *data); int linkedlist_insert(struct linkedlist *l, unsigned int idx, void *data); int linkedlist_is_empty(const struct linkedlist *l); unsigned int linkedlist_size(const struct linkedlist *l); void *linkedlist_get(const struct linkedlist *l, unsigned int idx); void *linkedlist_get_last(const struct linkedlist *l); void linkedlist_iterate(struct linkedlist *l); void *linkedlist_next(struct linkedlist *l); void *linkedlist_remove(struct linkedlist *l, unsigned int idx); void *linkedlist_remove_last(struct linkedlist *l); |
2.3 hashtableA chaining hashtable. |
|
2.4 hexdumpPrint a region of memory to a stream as hexadecimal characters. |
|
2.5 pathManipulate UNIX file system paths. |
struct path; struct path *path_new(const char *s); struct path *path_child_new(const struct path *parent, const char *child); void path_del(struct path *p); char *path_get(const struct path *p); char *path_get_canonical(struct path *p); int path_compare(const struct path *p1, const struct path *p2); char *path_get_absolute(const struct path *p); char *path_get_name(const struct path *p); char *path_get_parent(const struct path *p); |
2.6 logLog different classes of messages to associated files. Log ids 0, 1, and 2 are reserved for |
|
2.7 encdecEncode and decode primative objects such as integers, strings, and times. 2.7.1 integers Encode integers. |
size_t enc_uint16be(uint16_t s, char *dst); size_t enc_uint32be(uint32_t i, char *dst); size_t enc_uint16le(uint16_t s, char *dst); size_t enc_uint32le(uint32_t i, char *dst); |
|
Decode integers. |
uint16_t dec_uint16be(const char *src); uint32_t dec_uint32be(const char *src); uint16_t dec_uint16le(const char *src); uint32_t dec_uint32le(const char *src); |
|
2.7.2 strings The following encodings are supported. |
|
|
Encode |
size_t enc_strn(const wchar_t *src, unsigned int n, char *dst, size_t max, int enc); |
|
Decode |
|
|
2.7.3 times Encode and decode |
|
2.8 profileA simple memory profiler. These functions should not be used
directly. Simply include the |
void profile_del(void); void *profile_calloc(size_t nmemb, size_t size, const char *file, unsigned int line); void *profile_malloc(size_t size, const char *file, unsigned int line); void profile_free(void *ptr); void *profile_realloc(void *ptr, size_t size, const char *file, unsigned int line); void profile_add(void *ptr, size_t size, const char *file, unsigned int line); #define calloc(nmemb, size) profile_calloc((nmemb), (size), __FILE__, __LINE__) #define malloc(size) profile_malloc((size), __FILE__, __LINE__) #define free profile_free #define realloc(ptr, size) profile_realloc((ptr), (size), __FILE__, __LINE__) #define PROFILE_ADD(ptr, size) profile_add((ptr), (size), __FILE__, __LINE__) void profile_report(FILE *out); |