Elektra
0.9.5
|
Helper for memory management. More...
Enumerations | |
enum | elektraLookupOptions { KDB_O_SPEC = 1 << 15, KDB_O_CREATE = 1 << 16, KDB_O_NOCASCADING = 1 << 17, KDB_O_NOSPEC = 1 << 18, KDB_O_NODEFAULT = 1 << 19, KDB_O_CALLBACK = 1 << 20, KDB_O_OPMPHM = 1 << 21, KDB_O_BINSEARCH = 1 << 22 } |
More lookup options. More... | |
Functions | |
void * | elektraMalloc (size_t size) |
Allocate memory for Elektra. More... | |
void * | elektraCalloc (size_t size) |
Allocate memory for Elektra. More... | |
void | elektraFree (void *ptr) |
Free memory of Elektra or its backends. More... | |
int | elektraRealloc (void **buffer, size_t size) |
Reallocate Storage in a save way. More... | |
char * | elektraStrDup (const char *s) |
Copy string into new allocated memory. More... | |
char * | elektraStrNDup (const char *s, size_t l) |
Copy buffer into new allocated memory. More... | |
char char * | elektraVFormat (const char *format, va_list arg_list) |
Does string formatting in fresh allocated memory. More... | |
int | elektraStrCmp (const char *s1, const char *s2) |
Compare Strings. More... | |
int | elektraStrNCmp (const char *s1, const char *s2, size_t n) |
Compare Strings up to a maximum length. More... | |
int | elektraStrCaseCmp (const char *s1, const char *s2) |
Compare Strings ignoring case. More... | |
int | elektraStrNCaseCmp (const char *s1, const char *s2, size_t n) |
Compare Strings ignoring case up to a maximum length. More... | |
int | elektraMemCaseCmp (const char *s1, const char *s2, size_t size) |
Compare two memory regions but make cmp chars uppercase before comparison. More... | |
size_t | elektraStrLen (const char *s) |
Calculates the length in bytes of a string. More... | |
Helper for memory management.
Should be always preferred. Can be used for profiling and tracing.
enum elektraLookupOptions |
More lookup options.
Enumerator | |
---|---|
KDB_O_SPEC | Use the passed key as specification, instead of looking up the specification first. |
KDB_O_CREATE | Create the key if it was not found. |
KDB_O_NOCASCADING | Disable cascading search for keys starting with /. |
KDB_O_NOSPEC | Do not use specification for cascading keys (internal) |
KDB_O_NODEFAULT | Do not honor the default spec (internal) |
KDB_O_CALLBACK | For spec:/ lookups that traverse deeper into hierarchy (callback in ksLookup()) |
KDB_O_OPMPHM | Overrule ksLookup search predictor to use OPMPHM, make sure to set ENABLE_OPTIMIZATIONS=ON at cmake. |
KDB_O_BINSEARCH | Overrule ksLookup search predictor to use Binary search for lookup. |
void* elektraCalloc | ( | size_t | size | ) |
Allocate memory for Elektra.
Memory will be set to 0.
size | the requested size |
void elektraFree | ( | void * | ptr | ) |
Free memory of Elektra or its backends.
ptr | the pointer to free |
If ptr is NULL, no operation is performed.
void* elektraMalloc | ( | size_t | size | ) |
Allocate memory for Elektra.
size | the requested size |
This function is compatible to ANSI-C malloc
int elektraMemCaseCmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | size | ||
) |
Compare two memory regions but make cmp chars uppercase before comparison.
s1 | The first string to be compared |
s2 | The second string to be compared |
size | to be compared |
0 | if s1 matches s2 |
int elektraRealloc | ( | void ** | buffer, |
size_t | size | ||
) |
Reallocate Storage in a save way.
buffer | is a pointer to a elektraMalloc |
size | is the new size for the memory |
-1 | on failure |
0 | on success |
int elektraStrCaseCmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Compare Strings ignoring case.
s1 | The first string to be compared |
s2 | The second string to be compared |
0 | if s1 matches s2 |
int elektraStrCmp | ( | const char * | s1, |
const char * | s2 | ||
) |
Compare Strings.
s1 | The first string to be compared |
s2 | The second string to be compared |
0 | if s1 matches s2 |
char* elektraStrDup | ( | const char * | s | ) |
Copy string into new allocated memory.
You need to free the memory yourself.
s | the null-terminated string to duplicate |
size_t elektraStrLen | ( | 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, elektraStrLen() count bytes including the ending NULL.
It must not be used to search for / in the name, because it does not consider escaping. Instead use the unescaped name.
s | the string to get the length from |
int elektraStrNCaseCmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Compare Strings ignoring case up to a maximum length.
s1 | The first string to be compared |
s2 | The second string to be compared |
n | The maximum length to be compared |
0 | if s1 matches s2 |
int elektraStrNCmp | ( | const char * | s1, |
const char * | s2, | ||
size_t | n | ||
) |
Compare Strings up to a maximum length.
s1 | The first string to be compared |
s2 | The second string to be compared |
n | The maximum length to be compared |
0 | if s1 matches s2 |
char* elektraStrNDup | ( | const char * | s, |
size_t | l | ||
) |
Copy buffer into new allocated memory.
You need to free the memory yourself.
This function also works with \0 characters in the buffer. The length is taken as given, it must be correct.
s | must be an allocated buffer |
l | the length of s |
char char* elektraVFormat | ( | const char * | format, |
va_list | arg_list | ||
) |
Does string formatting in fresh allocated memory.
format | as in vprintf() |
arg_list | as in vprintf() |