libircbot
library providing a framework for implementing an IRC bot
Loading...
Searching...
No Matches
util.h File Reference

collection of generic utility functions More...

#include <ircbot/decl.h>
#include <stddef.h>

Go to the source code of this file.

Functions

void * IB_xmalloc (size_t size)
 Allocate memory. More...
 
void * IB_xrealloc (void *ptr, size_t size)
 Reallocate memory. More...
 
char * IB_copystr (const char *src)
 Copy a string. More...
 
char * IB_lowerstr (const char *src)
 Convert string to lowercase. More...
 
char * IB_joinstr (const char *delim, char **strings)
 Join an array of strings in a single one. More...
 

Detailed Description

collection of generic utility functions

Function Documentation

◆ IB_copystr()

char * IB_copystr ( const char *  src)

Copy a string.

Parameters
srcthe string to copy
Returns
a dyanmically allocated copy of the string

◆ IB_joinstr()

char * IB_joinstr ( const char *  delim,
char **  strings 
)

Join an array of strings in a single one.

Parameters
delimthe delimiter to place between individual strings
stringsarray of individual strings, terminated by a NULL pointer
Returns
a newly allocated joined string

◆ IB_lowerstr()

char * IB_lowerstr ( const char *  src)

Convert string to lowercase.

Parameters
srcthe original string
Returns
a dynamically allocated copy with all characters converted to lowercase

◆ IB_xmalloc()

void * IB_xmalloc ( size_t  size)

Allocate memory.

This replaces malloc(), but always returns successful. On allocation error, a service panic is triggered instead.

Parameters
sizethe size of the memory to allocate

◆ IB_xrealloc()

void * IB_xrealloc ( void *  ptr,
size_t  size 
)

Reallocate memory.

This replaces realloc() but always returns successful. On allocation error, a service panic is triggered instead.

Parameters
ptrpointer to previously allocated memory
sizenew size for the allocated memory