Skip to content

Commit 9e376ce

Browse files
Added more libs, updated readme
1 parent eee5876 commit 9e376ce

File tree

6 files changed

+373754
-46
lines changed

6 files changed

+373754
-46
lines changed

README.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/W7W1B1W7)
2-
31
# libs
42
Single-file public domain libraries for C/C++ (dual licensed under MIT).
53

@@ -12,3 +10,37 @@ Single-file public domain libraries for C/C++ (dual licensed under MIT).
1210
* [strpool.h](docs/strpool.md) - Highly efficient string pool for C/C++.
1311
* [thread.h](docs/thread.md) - Cross platform threading functions for C/C++.
1412

13+
14+
# wip libs
15+
More libs, work-in-progress, some are unfinished, some are complete but lacking documentation.
16+
17+
* array.h - Dynamic array library for C/C++.
18+
* buffer.h - Memory buffer with read/write operations, for C/C++.
19+
* crtemu.h - Cathode ray tube emulation shader for C/C++.
20+
* cstr.h - String interning and manipulation library for C/C++.
21+
* dialog.h - Loading and management of dialogs for a custom game dialog system.
22+
* dir.h - Directory listing functions for C/C++.
23+
* frametimer.h - Framerate timer functionality, for C/C++.
24+
* id3tag.h - Read/write ID3 tags from/to mp3 files in C/C++.
25+
* img.h - Image processing functions for C/C++.
26+
* mus.h - Parsing library for MUS music files (as used in DOS games).
27+
* paldither.h - Convert true-color image to custom palette, with dither.
28+
* palettize.h - Median-cut palette generation and remapping for C/C++.
29+
* palrle.h - Run-length encoding of palettized bitmaps, for C/C++.
30+
* pixelfont.h - Custom pixel font format builder and renderer.
31+
* sysfont.h - Simple debug text renderer for C/C++.
32+
* testfw.h - Basic test framework for C/C++.
33+
34+
35+
# repackaged libs
36+
Single-file header-only versions of libs written by other people, released under the same license as the original lib.
37+
I recommend using the latest version of these libs - I only repackage them like this to fit my single-file-libs centered
38+
dev paradigm, and if you don't absolutely need that, you are better off using the original multi-file versions.
39+
40+
* ftplib.h - FTP client lib for C/C++. *By Thomas Pfau.*
41+
* hoedown.h - Markdown to HTML renderer for C/C++. *By Porte/Marti/Mendez/Torres.*
42+
* libxdiff.h - File Differential Library. *By Davide Libenzi.*
43+
* lzma.h - LZMA data compression/decompression library. *By Igor Pavlov.*
44+
* opl.h - OPL3 (SoundBlaster16) emulation with MIDI compatible interface. *Based on code by Aaron Giles and Mateusz Viste*
45+
* samplerate.h - Sample-rate converter (libsamplerate) for C/C++. *By Erik de Castro Lopo*
46+
* speech.h - Very basic text-to-speech synthesizer library for C/C++. *By Jari Komppa / Nick Ing-Simmons (et al)*

array.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ before you include this file in *one* C/C++ file to create the implementation.
2525
#define array_create( type ) ARRAY_CAST( (void*)internal_array_create( sizeof( type ), NULL ) )
2626
#define array_create_memctx( type, memctx ) ARRAY_CAST( (void*)internal_array_create( sizeof( type ), (memctx) ) )
2727
#define array_destroy( array ) internal_array_destroy( (struct internal_array_t*) (array) )
28-
#define array_add( array, item ) ARRAY_CAST( internal_array_add( (struct internal_array_t*) (array), (void*) (item) ) )
28+
#define array_add( array, item ) ARRAY_CAST( internal_array_add( (struct internal_array_t*) (array), (void*) (item), (int)sizeof( *item ) ) )
2929
#define array_remove( array, index ) internal_array_remove( (struct internal_array_t*) (array), (index) )
3030
#define array_remove_ordered( array, index ) internal_array_remove_ordered( (struct internal_array_t*) (array), (index) )
3131
#define array_get( array, index, item ) internal_array_get( (struct internal_array_t*) (array), (index), (void*) (item) )
@@ -71,7 +71,7 @@ struct internal_array_t;
7171

7272
struct internal_array_t* internal_array_create( int item_size, void* memctx );
7373
void internal_array_destroy( struct internal_array_t* array );
74-
void* internal_array_add( struct internal_array_t* array, void* item );
74+
void* internal_array_add( struct internal_array_t* array, void* item, int item_size );
7575
void internal_array_remove( struct internal_array_t* array, int index );
7676
void internal_array_remove_ordered( struct internal_array_t* array, int index );
7777
ARRAY_BOOL_T internal_array_get( struct internal_array_t* array, int index, void* item );
@@ -94,6 +94,12 @@ void* internal_array_item( struct internal_array_t* array, int index );
9494
#ifdef ARRAY_IMPLEMENTATION
9595
#undef ARRAY_IMPLEMENTATION
9696

97+
#ifndef ARRAY_ASSERT
98+
#define _CRT_NONSTDC_NO_DEPRECATE
99+
#define _CRT_SECURE_NO_WARNINGS
100+
#include <assert.h>
101+
#define ARRAY_ASSERT( condition, message ) assert( condition && message );
102+
#endif
97103

98104
#ifndef ARRAY_MALLOC
99105
#define _CRT_NONSTDC_NO_DEPRECATE
@@ -165,7 +171,8 @@ void internal_array_destroy( struct internal_array_t* array ) {
165171
}
166172

167173

168-
void* internal_array_add( struct internal_array_t* array, void* item ) {
174+
void* internal_array_add( struct internal_array_t* array, void* item, int item_size ) {
175+
ARRAY_ASSERT( item_size == array->item_size, "Invalid item" );
169176
if( array->count >= array->capacity ) {
170177
array->capacity *= 2;
171178
void* items = array->items;

0 commit comments

Comments
 (0)