You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libsxmp/ydaemon/idxstream.c

68 lines
1.6 KiB
C

/*
* Yet another daemon library especially designed to be used
* with libsxmp based daemons.
*
* (c) Alexander Vdolainen 2016 <avdolainen@zoho.com>
*
* libsxmp is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libsxmp is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
*
*/
#include <ydaemon/dataobject.h>
yd_idx_stream_t *yd_index_stream_init(void)
{
yd_idx_stream_t *is = malloc(sizeof(yd_idx_stream_t));
if(!is) return NULL;
else memset(is, 0, sizeof(yd_idx_stream_t));
list_init_head(&is->entries_wlist);
return is;
}
static inline void __empty_list(list_head_t *list)
{
list_node_t *iter, *siter;
yd_wlist_node_t *wlistnode;
list_for_each_safe(list, iter, siter){
wlistnode = container_of(iter, yd_wlist_node_t, node);
list_del(&wlistnode->node);
free(wlistnode);
}
return;
}
void yd_index_stream_destroy(yd_idx_stream_t *is)
{
if(!is) return;
else __empty_list(&is->entries_wlist);
free(is);
return;
}
void yd_index_stream_emptylist(yd_idx_stream_t *is)
{
if(!is) return;
else __empty_list(&is->entries_wlist);
return;
}