LibJAD Utility Routines
#include "jadutil.h"
Overview
LibJAD provides a set of routines to support working with the types of lists it commonly works with. Two string parsing routines are also provided as alternatives to the functions found in the standard library.
TYPE* malloc_array(TYPE,size)
TYPE | The type of array to allocate. |
size | The size of array to allocate. |
return | A newly allocated array. |
malloc_array is a convenance macro that allocates an array of the given size and type and casts the results back to the appropriate type.
void free_list(void** list, int size)
list | A list of pointers to be freed. |
size | The size of array to free. |
free_list frees up size pointers on the provided list, and then frees up the list itself. If any pointer on the list is NULL, that entry is skipped.
void free_ntlist(void** list)
list | A null terminated list of pointers to be freed. |
free_ntlist frees up every pointer on the provided list up to a null terminator, and then frees up the list itself.
char** strtotok(char* str, char* delim)
str | The string to parse. |
delim | A null terminated list of single character deliminators. |
return | A null terminated list of tokens (null terminated strings). |
strtotok splits a given string into a set of tokens, breaking it according to the specified delimiters. Delimiters are not reflected in the output, and if multiple delimiters appear in succession, then no blank field is output.
char** strtotok(char* str, char* delim)
str | The string to parse. |
delim | A null terminated list of single character deliminators. |
return | A null terminated list of tokens (null terminated strings). |
strtotok splits a given string into a set of tokens, breaking it according to the specified delimiters. Delimiters are not reflected in the output, and if multiple delimiters appear in succession, then no blank field is output.
char** strtofields(char* str, char* delim)
str | The string to parse. |
delim | A null terminated list of single character deliminators. |
return | A null terminated list of tokens (null terminated strings). |
strtofields splits a given string into a set of tokens, breaking it according to the specified delimiters. Delimiters are not reflected in the output, and if multiple delimiters appear in succession, then a string whose only character is the null terminator is output.