table of contents
| kdbhelper.h(3elektra) | Elektra | kdbhelper.h(3elektra) |
NAME¶
kdbhelper.h - Helper for memory management.
SYNOPSIS¶
#include 'kdbconfig.h'
#include <kdbtypes.h>
#include <stdarg.h>
#include <stddef.h>
Functions¶
void * elektraMalloc (size_t size)
Allocate memory for Elektra. " void * elektraCalloc (size_t size)
Allocate memory for Elektra. void elektraFree (void *ptr)
Free memory of Elektra or its backends. int elektraRealloc (void
**buffer, size_t size)
Reallocate Storage in a save way. char * elektraStrDup (const char *s)
Copy string into new allocated memory. char * elektraStrNDup (const
char *s, size_t l)
Copy buffer into new allocated memory. char * elektraFormat (const char
*format,...)
Does string formatting in fresh allocated memory. char * elektraVFormat
(const char *format, va_list arg_list)
Does string formatting in fresh allocated memory. int elektraStrCmp
(const char *s1, const char *s2)
Compare Strings. int elektraStrCaseCmp (const char *s1, const char *s2)
Compare Strings ignoring case. int elektraMemCaseCmp (const char *s1,
const char *s2, size_t size)
Compare two memory regions but make cmp chars uppercase before comparison.
size_t elektraStrLen (const char *s)
Calculates the length in bytes of a string.
Detailed Description¶
Helper for memory management.
Should be always preferred. Can be used for profiling and tracing.
Copyright:
Function Documentation¶
void* elektraCalloc (size_t size)¶
Allocate memory for Elektra. Memory will be set to 0.
Parameters:
See also:
char* elektraFormat (const char * format, ...)¶
Does string formatting in fresh allocated memory.
Parameters:
... as in printf()
Returns:
void elektraFree (void * ptr)¶
Free memory of Elektra or its backends.
Parameters:
If ptr is NULL, no operation is performed.
See also:
void* elektraMalloc (size_t size)¶
Allocate memory for Elektra.
if ((buffer = elektraMalloc (length)) == 0) {
// here comes the failure handler
// no allocation happened here, so don't use buffer
#if DEBUG
fprintf (stderr, "Allocation error");
#endif
// return with error
}
Parameters:
This function is compatible to ANSI-C elektraMalloc
See also:
elektraCalloc
int elektraMemCaseCmp (const char * s1, const char * s2, size_t size)¶
Compare two memory regions but make cmp chars uppercase before comparison.
Parameters:
s2 The second string to be compared
size to be compared
Returns:
Return values:
Returns:
int elektraRealloc (void ** buffer, size_t size)¶
Reallocate Storage in a save way.
if (elektraRealloc ((void **) & buffer, new_length) < 0) {
// here comes the failure handler
// you can still use the old buffer
#if DEBUG
fprintf (stderr, "Reallocation error0);
#endif
elektraFree (buffer);
buffer = 0;
// return with error
}
Parameters:
size is the new size for the memory
Return values:
0 on success
int elektraStrCaseCmp (const char * s1, const char * s2)¶
Compare Strings ignoring case.
Parameters:
s2 The second string to be compared
Returns:
Return values:
Returns:
int elektraStrCmp (const char * s1, const char * s2)¶
Compare Strings.
Parameters:
s2 The second string to be compared
Returns:
Return values:
Returns:
char* elektraStrDup (const char * s)¶
Copy string into new allocated memory. You need to free the memory yourself.
Note:
Parameters:
Returns:
Precondition:
See also:
elektraStrLen
elektraStrNDup
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.
See also:
Parameters:
Returns:
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.
Returns:
Parameters:
l the length of s
char* elektraVFormat (const char * format, va_list arg_list)¶
Does string formatting in fresh allocated memory.
Parameters:
arg_list as in vprintf()
Returns:
Author¶
Generated automatically by Doxygen for Elektra from the source code.
| Mon Jan 15 2018 | Version 0.8.20 |