Various modules solving daily C developer tasks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB

/******************************************************************************
*
* Copyright (c) 2017-2019 by Löwenware Ltd
* Please, refer LICENSE file for legal information
*
******************************************************************************/
/**
* @file list.h
* @author Ilja Kartašov <ik@lowenware.com>
* @brief cStuff List module header file
*
* @see https://lowenware.com/
*/
#ifndef CSTUFF_LIST_H_372E2D14_8DEE_4A7C_A5AB_8808A87DF436
#define CSTUFF_LIST_H_372E2D14_8DEE_4A7C_A5AB_8808A87DF436
#include "retcode.h"
#define cstuff_list_index(LIST, IDX) (LIST->items[IDX])
struct cstuff_list {
void **items;
int length;
int size;
};
typedef struct cstuff_list * CStuffList;
typedef void
(*CStuffListFree)(void *item);
CStuffRetcode
cstuff_list_init(CStuffList self, int size);
void
cstuff_list_release(CStuffList self, CStuffListFree item_free);
int
cstuff_list_append(CStuffList self, void *item);
int
cstuff_list_insert(CStuffList self, void *item, int index);
void *
cstuff_list_remove(CStuffList self, int index);
void
cstuff_list_remove_item(CStuffList self, void *item);
void
cstuff_list_set_item(CStuffList self, int index, void *value);
#endif /* !LIST_H */