Skip to content

Commit ce646e7

Browse files
committed
Remove _t suffix from all custom types (reserved for POSIX)
1 parent 232deec commit ce646e7

37 files changed

+337
-322
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,26 @@
99
[![Codecov](https://codecov.io/gh/cm-jones/libdsc/branch/main/graph/badge.svg)](https://codecov.io/gh/cm-jones/libdsc)
1010
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
1111

12-
libdsc is an open-source C library that features generic implementations of several C++ Standard Library containers.
12+
`libdsc` is an open-source C library featuring generic and memory-safe implementations of various containers provided by the C++ Standard Library.
1313

1414
## Features
1515

16-
- **Vector**: Dynamically-sized array
17-
- **Forward List**: Singly-linked list
18-
- **List**: Doubly-linked list
19-
- **Stack**: LIFO container
20-
- **Queue**: FIFO container
21-
- **Unordered Map**: Hash table for key-value pairs
22-
- **Unordered Set**: Hash table for unique elements
16+
`libdsc` implements the following containers:
2317

24-
All of these implementations are:
18+
- `vector`: dynamically-sized array
19+
- `forward_list`: singly-linked list
20+
- `list`: doubly-linked list
21+
- `stack`: LIFO container
22+
- `queue`: FIFO container
23+
- `unordered_map`: hash table for key-value pairs
24+
- `unordered_set`: hash table for unique elements
25+
26+
All containers are:
2527

2628
- Generic (can store any data type)
2729
- Memory safe (with proper error handling)
2830
- Thoroughly tested
29-
- Performance benchmarked against C++ counterparts
31+
- Benchmarked against C++ Standard Library counterparts
3032

3133
## Installing from source
3234

@@ -57,11 +59,13 @@ This will install:
5759
#include <libdsc/vector.h>
5860
#include <libdsc/list.h>
5961

62+
// Include other containers as needed ...
63+
6064
#include <stdio.h>
6165

6266
int main() {
6367
// Create a vector of integers
64-
dsc_vector_t *vec = vector_create(sizeof(int));
68+
dsc_vector *vec = vector_create(sizeof(int));
6569

6670
// Push some values
6771
for (size_t i = 0; i < 5; ++i) {
@@ -78,7 +82,7 @@ int main() {
7882
vector_destroy(vec);
7983

8084
// Create a list of integers
81-
dsc_list_t *list = list_create(sizeof(int));
85+
dsc_list *list = list_create(sizeof(int));
8286

8387
// Push some values
8488
for (size_t i = 0; i < 5; ++i) {
@@ -96,15 +100,15 @@ int main() {
96100
// Clean up
97101
list_destroy(list);
98102

99-
return 0;
103+
return EXIT_SUCCESS;
100104
}
101105
```
102106

103107
More examples can be found in the `examples` directory.
104108

105109
## Testing
106110

107-
libdsc uses Google Test for unit testing. To run the tests:
111+
Google Test is used for unit testing. To run the tests, after building the project:
108112

109113
```bash
110114
cd build
@@ -113,7 +117,7 @@ ctest --output-on-failure
113117

114118
## Benchmarking
115119

116-
Google Benchmark is used for benchmarking libdsc containers against the equivalent containers in the C++ Standard Library. Benchmarks are run weekly and can be found in the [Actions tab](https://github.com/cm-jones/libdsc/actions/workflows/benchmark.yaml) under the Benchmarks workflow. You can also run benchmarks locally:
120+
Google Benchmark is used to measure the performance of libdsc's containers against their equivalents in the C++ Standard Library. Benchmarks are run weekly automatically via GitHub Actions. You can also run the benchmarks locally:
117121

118122
```bash
119123
mkdir -p build
@@ -126,8 +130,8 @@ cd benchmarks
126130

127131
## Contributing
128132

129-
See [CONTRIBUTING.md](CONTRIBUTING.md).
133+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) carefully before you attempt to make contributions to this project.
130134

131135
## License
132136

133-
This project is licensed under the GPLv3. See [LICENSE](LICENSE) for details.
137+
`libdsc` is licensed under the GPLv3. See [LICENSE](LICENSE) for details.

benchmarks/benchmark_forward_list.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// Benchmark push_front
88
static void BM_ForwardListPushFront(benchmark::State &state) {
9-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
9+
dsc_forward_list *list = forward_list_create(sizeof(int));
1010

1111
for (auto _ : state) {
1212
int value = 42;
@@ -30,7 +30,7 @@ BENCHMARK(BM_StdForwardListPushFront)->Range(1, 1 << 20);
3030

3131
// Benchmark push_front and pop_front
3232
static void BM_ForwardListPushPopFront(benchmark::State &state) {
33-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
33+
dsc_forward_list *list = forward_list_create(sizeof(int));
3434

3535
for (auto _ : state) {
3636
int value = 42;
@@ -55,7 +55,7 @@ BENCHMARK(BM_StdForwardListPushPopFront)->Range(1, 1 << 20);
5555

5656
// Benchmark front access
5757
static void BM_ForwardListFront(benchmark::State &state) {
58-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
58+
dsc_forward_list *list = forward_list_create(sizeof(int));
5959
int value = 42;
6060
forward_list_push_front(list, &value);
6161

@@ -80,7 +80,7 @@ BENCHMARK(BM_StdForwardListFront)->Range(1 << 10, 1 << 20);
8080

8181
// Benchmark insert_after
8282
static void BM_ForwardListInsertAfter(benchmark::State &state) {
83-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
83+
dsc_forward_list *list = forward_list_create(sizeof(int));
8484
int value = 42;
8585
forward_list_push_front(list, &value);
8686
forward_list_node_t *pos = forward_list_begin(list);
@@ -108,7 +108,7 @@ BENCHMARK(BM_StdForwardListInsertAfter)->Range(1, 1 << 20);
108108

109109
// Benchmark size operation
110110
static void BM_ForwardListSize(benchmark::State &state) {
111-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
111+
dsc_forward_list *list = forward_list_create(sizeof(int));
112112
int value = 42;
113113
for (size_t i = 0; i < 1000; ++i) {
114114
forward_list_push_front(list, &value);
@@ -138,7 +138,7 @@ BENCHMARK(BM_StdForwardListSize)->Range(1 << 10, 1 << 20);
138138

139139
// Benchmark empty check
140140
static void BM_ForwardListEmpty(benchmark::State &state) {
141-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
141+
dsc_forward_list *list = forward_list_create(sizeof(int));
142142

143143
for (auto _ : state) {
144144
benchmark::DoNotOptimize(forward_list_empty(list));
@@ -160,7 +160,7 @@ BENCHMARK(BM_StdForwardListEmpty)->Range(1 << 10, 1 << 20);
160160

161161
// Benchmark erase_after operation
162162
static void BM_ForwardListEraseAfter(benchmark::State &state) {
163-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
163+
dsc_forward_list *list = forward_list_create(sizeof(int));
164164
int value = 42;
165165
forward_list_push_front(list, &value);
166166
forward_list_node_t *pos = forward_list_begin(list);
@@ -195,7 +195,7 @@ BENCHMARK(BM_StdForwardListEraseAfter)->Range(1 << 10, 1 << 20);
195195

196196
// Benchmark clear operation
197197
static void BM_ForwardListClear(benchmark::State &state) {
198-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
198+
dsc_forward_list *list = forward_list_create(sizeof(int));
199199
int value = 42;
200200

201201
for (auto _ : state) {
@@ -232,7 +232,7 @@ BENCHMARK(BM_StdForwardListClear)->Range(1 << 10, 1 << 20);
232232

233233
// Benchmark iterator operations (begin/end traversal)
234234
static void BM_ForwardListTraversal(benchmark::State &state) {
235-
dsc_forward_list_t *list = forward_list_create(sizeof(int));
235+
dsc_forward_list *list = forward_list_create(sizeof(int));
236236
int value = 42;
237237
for (size_t i = 0; i < 1000; ++i) {
238238
forward_list_push_front(list, &value);

benchmarks/benchmark_list.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// Benchmark push_front
88
static void BM_ListPushFront(benchmark::State &state) {
9-
dsc_list_t *list = list_create(sizeof(int));
9+
dsc_list *list = list_create(sizeof(int));
1010

1111
for (auto _ : state) {
1212
int value = 42;
@@ -30,7 +30,7 @@ BENCHMARK(BM_StdListPushFront)->Range(1, 1 << 20);
3030

3131
// Benchmark push_back
3232
static void BM_ListPushBack(benchmark::State &state) {
33-
dsc_list_t *list = list_create(sizeof(int));
33+
dsc_list *list = list_create(sizeof(int));
3434

3535
for (auto _ : state) {
3636
int value = 42;
@@ -54,7 +54,7 @@ BENCHMARK(BM_StdListPushBack)->Range(1, 1 << 20);
5454

5555
// Benchmark push_front and pop_front
5656
static void BM_ListPushPopFront(benchmark::State &state) {
57-
dsc_list_t *list = list_create(sizeof(int));
57+
dsc_list *list = list_create(sizeof(int));
5858

5959
for (auto _ : state) {
6060
int value = 42;
@@ -79,7 +79,7 @@ BENCHMARK(BM_StdListPushPopFront)->Range(1, 1 << 20);
7979

8080
// Benchmark push_back and pop_back
8181
static void BM_ListPushPopBack(benchmark::State &state) {
82-
dsc_list_t *list = list_create(sizeof(int));
82+
dsc_list *list = list_create(sizeof(int));
8383

8484
for (auto _ : state) {
8585
int value = 42;
@@ -104,7 +104,7 @@ BENCHMARK(BM_StdListPushPopBack)->Range(1, 1 << 20);
104104

105105
// Benchmark front access
106106
static void BM_ListFront(benchmark::State &state) {
107-
dsc_list_t *list = list_create(sizeof(int));
107+
dsc_list *list = list_create(sizeof(int));
108108
int value = 42;
109109
list_push_front(list, &value);
110110

@@ -129,7 +129,7 @@ BENCHMARK(BM_StdListFront)->Range(1 << 10, 1 << 20);
129129

130130
// Benchmark back access
131131
static void BM_ListBack(benchmark::State &state) {
132-
dsc_list_t *list = list_create(sizeof(int));
132+
dsc_list *list = list_create(sizeof(int));
133133
int value = 42;
134134
list_push_back(list, &value);
135135

@@ -154,7 +154,7 @@ BENCHMARK(BM_StdListBack)->Range(1 << 10, 1 << 20);
154154

155155
// Benchmark size operation
156156
static void BM_ListSize(benchmark::State &state) {
157-
dsc_list_t *list = list_create(sizeof(int));
157+
dsc_list *list = list_create(sizeof(int));
158158
int value = 42;
159159
for (size_t i = 0; i < 1000; ++i) {
160160
list_push_front(list, &value);
@@ -183,7 +183,7 @@ BENCHMARK(BM_StdListSize)->Range(1 << 10, 1 << 20);
183183

184184
// Benchmark empty check
185185
static void BM_ListEmpty(benchmark::State &state) {
186-
dsc_list_t *list = list_create(sizeof(int));
186+
dsc_list *list = list_create(sizeof(int));
187187

188188
for (auto _ : state) {
189189
benchmark::DoNotOptimize(list_empty(list));
@@ -205,7 +205,7 @@ BENCHMARK(BM_StdListEmpty)->Range(1 << 10, 1 << 20);
205205

206206
// Benchmark insert operation
207207
static void BM_ListInsert(benchmark::State &state) {
208-
dsc_list_t *list = list_create(sizeof(int));
208+
dsc_list *list = list_create(sizeof(int));
209209
int value = 42;
210210

211211
for (auto _ : state) {
@@ -240,7 +240,7 @@ BENCHMARK(BM_StdListInsert)->Range(1 << 10, 1 << 20);
240240

241241
// Benchmark erase operation
242242
static void BM_ListErase(benchmark::State &state) {
243-
dsc_list_t *list = list_create(sizeof(int));
243+
dsc_list *list = list_create(sizeof(int));
244244
int value = 42;
245245
list_push_back(list, &value);
246246
list_push_back(list, &value);
@@ -276,7 +276,7 @@ BENCHMARK(BM_StdListErase)->Range(1 << 10, 1 << 20);
276276

277277
// Benchmark clear operation
278278
static void BM_ListClear(benchmark::State &state) {
279-
dsc_list_t *list = list_create(sizeof(int));
279+
dsc_list *list = list_create(sizeof(int));
280280
int value = 42;
281281

282282
for (auto _ : state) {
@@ -313,7 +313,7 @@ BENCHMARK(BM_StdListClear)->Range(1 << 10, 1 << 20);
313313

314314
// Benchmark forward iterator traversal
315315
static void BM_ListForwardTraversal(benchmark::State &state) {
316-
dsc_list_t *list = list_create(sizeof(int));
316+
dsc_list *list = list_create(sizeof(int));
317317
int value = 42;
318318
for (size_t i = 0; i < 1000; ++i) {
319319
list_push_back(list, &value);
@@ -348,7 +348,7 @@ BENCHMARK(BM_StdListForwardTraversal)->Range(1 << 10, 1 << 20);
348348

349349
// Benchmark reverse iterator traversal
350350
static void BM_ListReverseTraversal(benchmark::State &state) {
351-
dsc_list_t *list = list_create(sizeof(int));
351+
dsc_list *list = list_create(sizeof(int));
352352
int value = 42;
353353
for (size_t i = 0; i < 1000; ++i) {
354354
list_push_back(list, &value);

0 commit comments

Comments
 (0)