Skip to content

Repository files navigation

LC: lambda-larry C

STB style single header library

Overview

librarycategoryC Versiondescription
lc.hCore>=c23Monolith library inspired by odin lang, contains everything
lc_hashmap.hCore>=c99Open addressing hashmap
lc_deflate.hCompression>=c23Deflate decompression routine
lc_utf8.hEncoding>=c99UTF-8 decode/encode
lc_csv.hParser>=c99BYOB csv parser
lc_ini.hParser>=c99BYOB ini parser
lc_json.hParser>=c99BYOB json parser
lc_rng.hRNG>=c99PCG32 random number generator
lc_vfs.hPlatform>=c11Virtual filesystem interface
lc_hash.hUtil>=c99Hashing algorithm
lc_base64.hEncoding>=c99Base64 encoding/decoding
lc_lex_c.hLexer>=gnu99C lexer

Zero allocation API design

Libraries that does not do any allocation, will be marked as BYOB (Bring Your Own Buffer).

The user is expected to provide their own allocated buffer, instead of the implementation uses malloc or custom allocator.

#defineLC_IMPLEMENTATION#include"lc_csv.h"#include<stdio.h>externintmain(void)
{
conststructlc_svcsv_content=sv_c(
"name,age,team\r\n""larry,22,red\r\n""alice,20,jng\r\n"
);
structlc_csvcsv= {
.state.buf=csv_content,
.config.delimiter=',',
};
structlc_csv_rowrow= {};
lc_csv_iter(&csv, &row);
while (lc_csv_iter(&csv, &row)) {
externboollc_csv_row_iter(
structlc_csv*csv,
structlc_csv_row*row,
size_tn, charout[restrict n], // <-- BYOB (Bring Your Own Buffer)structlc_sv*field
);
charbuffer[128];
structlc_svfield= {};
lc_csv_row_iter(&csv, &row, sizeofbuffer, buffer, &field);
printf("name: %.*s\n", (int)field.length, field.s);
lc_csv_row_iter(&csv, &row, sizeofbuffer, buffer, &field);
printf("age: %.*s\n", (int)field.length, field.s);
lc_csv_row_iter(&csv, &row, sizeofbuffer, buffer, &field);
printf("team: %.*s\n", (int)field.length, field.s);
}
return0;
}

About

Personal war chest of C code as single header library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages