Elektra Projekt
Functions
KDB Backends :: Internal Helper for Elektra

Internal Methods for Elektra and Backends. More...

Functions

int kdbiStrCaseCmp (const char *s1, const char *s2)
 
int kdbiRealloc (void **buffer, size_t size)
 
void kdbiFree (void *ptr)
 
char * kdbiStrDup (const char *s)
 
size_t kdbiStrLen (const char *s)
 

Detailed Description

Internal Methods for Elektra and Backends.

To use them:

#include <kdbbackend.h>

There are some areas where libraries have to reimplement some basic functions to archive support for non-standard systems, for testing purposes or to provide a little more convenience.

Function Documentation

void kdbiFree ( void *  ptr)

Free memory of elektra or its backends.

Parameters
ptrthe pointer to free
See Also
kdbiMalloc
int kdbiRealloc ( void **  buffer,
size_t  size 
)

Reallocate Storage in a save way.

if (kdbiRealloc ((void **) & buffer, new_length) < 0) {
// here comes the failure handler
// you can still use the old buffer
#if DEBUG
fprintf (stderr, "Reallocation error\n");
#endif
free (buffer);
buffer = 0;
// return with error
}
Parameters
bufferis a pointer to a malloc
sizeis the new size for the memory
Returns
-1 on failure
0 on success
int kdbiStrCaseCmp ( const char *  s1,
const char *  s2 
)

Compare Strings ignoring case.

Parameters
s1The first string to be compared
s2The second string to be compared
Returns
a negative number if s1 is less than s2
0 if s1 matches s2
a positive number if s1 is greater than s2
char* kdbiStrDup ( const char *  s)

Copy string into new allocated memory.

You need to free the memory yourself.

Parameters
sthe null-terminated string to duplicate
See Also
kdbiFree
kdbiStrLen
size_t kdbiStrLen ( const char *  s)

Calculates the length in bytes of a string.

This function differs from strlen() because it is Unicode and multibyte chars safe. While strlen() counts characters and ignores the final NULL, kdbiStrLen() count bytes including the ending NULL.

Parameters
sthe string to get the length from
Returns
number of bytes used by the string, including the final NULL.