groups = pakfire_package_get_strings(pkg, PAKFIRE_PKG_GROUPS);
if (groups) {
// Join everything together as SQLite doesn't support arrays
- __groups = pakfire_string_join(groups, " ");
+ __groups = pakfire_string_join((const char**)groups, " ");
if (!__groups) {
r = 1;
goto ERROR;
int pakfire_string_partition(const char* s, const char* delim, char** s1, char** s2);
char* pakfire_string_replace(const char* s, const char* pattern, const char* repl);
-char* pakfire_string_join(char** list, const char* delim);
+char* pakfire_string_join(const char** list, const char* delim);
/*
Simple operations, usually used in the linter...
elements[count] = NULL;
// All okay, concat result string
- s = pakfire_string_join(elements, "\n");
+ s = pakfire_string_join((const char**)elements, "\n");
ERROR:
if (transaction)
return NULL;
}
-char* pakfire_string_join(char** list, const char* delim) {
+char* pakfire_string_join(const char** list, const char* delim) {
// Validate input
if (!list || !delim) {
errno = EINVAL;
unsigned int elements = 0;
// Count the number of elements and the total length
- for (char** item = list; *item; item++) {
+ for (const char** item = list; *item; item++) {
length += strlen(*item);
elements++;
}
size_t bytes_left = length + 1;
size_t bytes_written;
- for (char** item = list; *item; item++) {
+ for (const char** item = list; *item; item++) {
bytes_written = snprintf(p, bytes_left, "%s", *item);
bytes_left -= bytes_written;
char* s = NULL;
// Some test elements
- char* elements1[] = {
+ const char* elements1[] = {
"A",
"B",
"C",
s = NULL;
}
- char* elements2[] = {
+ const char* elements2[] = {
"",
"",
"",
s = pakfire_string_join(NULL, "\n");
ASSERT_ERRNO(!s, EINVAL);
- char* elements3[] = {
+ const char* elements3[] = {
NULL,
};