Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
data_linked_list.h
Go to the documentation of this file.
1 /*
2  * data_linked_list.h
3  *
4  * Created on: 2 Aug 2022
5  * Author: billy
6  */
7 
8 #ifndef CORE_SHARED_UTIL_INCLUDE_CONTAINERS_DATA_LINKED_LIST_H_
9 #define CORE_SHARED_UTIL_INCLUDE_CONTAINERS_DATA_LINKED_LIST_H_
10 
11 
12 
14 #include "linked_list.h"
15 #include "memory_allocations.h"
16 #include "typedefs.h"
17 
18 
19 #ifdef __cplusplus
20  extern "C" {
21 #endif
22 
23 
32 typedef struct DataListNode
33 {
36 
38  char *dln_data_p;
39 
41  size_t dln_data_size;
42 
43 } DataListNode;
44 
45 
54 GRASSROOTS_UTIL_API DataListNode *AllocateDataListNode (const char *data_p, const size_t data_size);
55 
56 
63 GRASSROOTS_UTIL_API void FreeDataListNode (ListItem * const node_p);
64 
65 
66 
67 
74 GRASSROOTS_UTIL_API LinkedList *AllocateDataLinkedList (void);
75 
76 
77 
88 GRASSROOTS_UTIL_API bool AddDataToDataLinkedList (LinkedList *list_p, const char *data_p, const size_t data_size);
89 
90 
91 GRASSROOTS_UTIL_API char *GetAllDataFromDataLinkedList (LinkedList *list_p, size_t *size_p);
92 
93 
94 GRASSROOTS_UTIL_API bool WriteAllDataFromDataLinkedList (LinkedList *list_p, const char * const filename_s, size_t *size_p);
95 
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 
102 #endif /* CORE_SHARED_UTIL_INCLUDE_CONTAINERS_DATA_LINKED_LIST_H_ */
DataListNode::AllocateDataListNode
DataListNode * AllocateDataListNode(const char *data_p, const size_t data_size)
Create a new DataListNode.
grassroots_util_library.h
GetAllDataFromDataLinkedList
char * GetAllDataFromDataLinkedList(LinkedList *list_p, size_t *size_p)
DataListNode
A ListNode for LinkedLists that also stores arbitrary blocks of data.
Definition: data_linked_list.h:32
typedefs.h
WriteAllDataFromDataLinkedList
bool WriteAllDataFromDataLinkedList(LinkedList *list_p, const char *const filename_s, size_t *size_p)
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
DataListNode::FreeDataListNode
void FreeDataListNode(ListItem *const node_p)
Free a DataListNode.
DataListNode::dln_data_size
size_t dln_data_size
The size in bytes of the stored data.
Definition: data_linked_list.h:41
memory_allocations.h
linked_list.h
A doubly-linked list.
DataListNode::dln_node
ListItem dln_node
The ListNode.
Definition: data_linked_list.h:35
DataListNode::dln_data_p
char * dln_data_p
The data to store.
Definition: data_linked_list.h:38
GRASSROOTS_UTIL_API
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47
ListItem
A doubly-linked node that points to its predecessor and successor.
Definition: linked_list.h:43