sl_add (3)
Leading comments
$NetBSD: stringlist.3,v 1.15 2010/05/06 09:46:49 jruoho Exp $ Copyright (c) 1997, 1999 The NetBSD Foundation, Inc. All rights reserved. This file was contributed to The NetBSD Foundation by Luke Mewburn. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Red...
NAME
stringlist sl_init sl_add sl_free sl_find sl_delete - stringlist manipulation functionsLIBRARY
Lb libbsdSYNOPSIS
In stringlist.h (See libbsd(7) for include usage.) Ft StringList * Fn sl_init void Ft int Fn sl_add StringList *sl char *item Ft void Fn sl_free StringList *sl int freeall Ft char * Fn sl_find StringList *sl const char *item Ft int Fn sl_delete StringList *sl const char *item int freeitDESCRIPTION
The transmission-daemon functions manipulate stringlists, which are lists of strings that extend automatically if necessary.The StringList structure has the following definition:
typedef struct _stringlist { char **sl_str; size_t sl_max; size_t sl_cur; } StringList;
where:
- sl_str
- is a pointer to the base of the array containing the list,
- sl_max
- is the size of sl_str and
- sl_cur
- is the offset in sl_str of the current element.
The following stringlist manipulation functions are available:
- Fn sl_init
- Create a stringlist. Returns a pointer to a StringList or NULL in case of failure.
- Fn sl_free
- Releases memory occupied by sl and the sl-Gt]sl_str array. If freeall is non-zero, then each of the items within sl-Gt]sl_str is released as well.
- Fn sl_add
- Add item to sl-Gt]sl_str at sl-Gt]sl_cur extending the size of sl-Gt]sl_str Returns zero upon success, -1 upon failure.
- Fn sl_find
- Find item in sl returning NULL if it's not found.
- Fn sl_delete
- Remove item from the list. If freeit is non-zero, the string is freed. Returns 0 if the name is found and -1 if the name is not found.