/******************************************************************************/ struct list *
list_create_sized(unsignedint size)
{ struct list *self;
/******************************************************************************/
tbus
list_get_item(conststruct list *self, int index)
{ if (index < 0 || index >= self->count)
{ return0;
}
return self->items[index];
}
/******************************************************************************/ void
list_clear(struct list *self)
{ int i;
if (self->auto_free)
{ for (i = 0; i < self->count; i++)
{
free((void *)self->items[i]);
self->items[i] = 0;
}
}
/******************************************************************************/ int
list_index_of(struct list *self, tbus item)
{ int i;
for (i = 0; i < self->count; i++)
{ if (self->items[i] == item)
{ return i;
}
}
return -1;
}
/******************************************************************************/ void
list_remove_item(struct list *self, int index)
{ int i;
if (index >= 0 && index < self->count)
{ if (self->auto_free)
{
free((void *)self->items[index]);
self->items[index] = 0;
}
for (i = index; i < (self->count - 1); i++)
{
self->items[i] = self->items[i + 1];
}
self->count--;
}
}
int
list_insert_item(struct list *self, int index, tbus item)
{ int i;
if (index > self->count)
{
index = self->count;
} elseif (index < 0)
{
index = 0;
}
if (self->count == self->alloc_size && !grow_list(self))
{ return0;
}
// Move all the items above this location up one for (i = self->count ; i > index ; --i)
{
self->items[i] = self->items[i - 1];
}
self->count++;
self->items[index] = item; return1;
}
/******************************************************************************/ int
list_add_strdup(struct list *self, constchar *str)
{ int rv; char *dup;
/******************************************************************************/ int
list_add_strdup_multi(struct list *self, ...)
{
va_list ap; int entry_count = self->count; constchar *s; int rv = 1;
if (rv == 0)
{ // Remove the additional items we added while (self->count > entry_count)
{
list_remove_item(self, self->count - 1);
}
}
return rv;
} /******************************************************************************/ /* append one list to another using strdup for each item in the list */ /* begins copy at start_index, a zero based index on the source list */ int
list_append_list_strdup(struct list *self, struct list *dest, int start_index)
{ int index; int rv = 1; int entry_dest_count = dest->count;
for (index = start_index; index < self->count; index++)
{ constchar *item = (constchar *)list_get_item(self, index); if (!list_add_strdup(dest, item))
{
rv = 0; break;
}
}
if (rv == 0)
{ // Remove the additional items we added while (dest->count > entry_dest_count)
{
list_remove_item(dest, dest->count - 1);
}
}
return rv;
}
/******************************************************************************/ void
list_dump_items(struct list *self)
{ int index;
if (self->count == 0)
{
LOG_DEVEL(LOG_LEVEL_TRACE, "List is empty");
}
for (index = 0; index < self->count; index++)
{
LOG_DEVEL(LOG_LEVEL_TRACE, "%d: %p", index, (void *) list_get_item(self, index));
}
}
/******************************************************************************/ /** *Appendsastringfragmenttoalist *@param[in,out]startPointertostartoffragment(byreference) *@paramendPointertoonepastendoffragment *@paramlistListtoappendto *@result1forsuccess * *Intheeventofamemoryfailure,0isreturnedandthelistisdeleted.
*/ int
split_string_append_fragment(constchar **start, constchar *end, struct list *list)
{ constunsignedint len = end - *start; char *copy = (char *)malloc(len + 1); if (copy == NULL)
{
list_delete(list); return0;
}
g_memcpy(copy, *start, len);
copy[len] = '\0'; if (!list_add_item(list, (tintptr)copy))
{
g_free(copy);
list_delete(list); return0;
}
*start = end + 1; return1;
}
/******************************************************************************/ struct list *
split_string_into_list(constchar *str, char character)
{ struct list *result = list_create(); if (result == NULL)
{ return result;
}
result->auto_free = 1;
if (str == NULL)
{ return result;
}
constchar *p; while ((p = g_strchr(str, character)) != NULL)
{ if (!split_string_append_fragment(&str, p, result))
{ return NULL;
}
}
if (*str != '\0')
{ if (!split_string_append_fragment(&str, str + g_strlen(str), result))
{ return NULL;
}
} return result;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-07-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.