This action will force synchronization from 三字经/facil.io, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
The facil.io framework is based on a modular design, which means many of the modules can be extracted and used independently as separate libraries.
The following libraries consist of a single header file that can be used independently.
Simply copy the header file to your project and enjoy.
Please note that this isn't a comprehensive list (for example, the Base64 library and SHA256 libraries aren't mentioned).
These type libraries are designed to make many common tasks easy while offering an easy to use API.
They are all designed to use a data container (that can be allocated either on the stack or on the heap) as well as dynamic memory management, for maximum flexibility.
And although they often prefer ease of use over performance, they are very libraries.
Dynamic String Library: this library is easy to use and helps with authoring binary and C Strings.
// container on the stack fio_str_s str = FIO_STR_INIT; fio_str_write(&str, "Hello", 5); fio_str_printf(&str, " world, %d", 42); printf("%s\n", fio_str_data(&str)); // "Hello world, 42" fio_str_free(&str); // container on the heap fio_str_s *str = malloc(sozeof(*str)); *str = FIO_STR_INIT; // use ... and ... free when done: fio_str_free(str); free(str);
It should be noted that short Strings (up to 30 bytes on 64bit machines) will be stored within the container without additional memory allocations, improving performance for many common use cases.
Dynamic Array Library: was designed to make dynamic arrays easy to handle.
// container on the stack (can also be placed on the heap). fio_ary_s ary = FIO_ARY_INIT; fio_ary_push(&ary, (void *)1); printf("Array pop value: %zd", (size_t)fio_ary_pop(&ary)); fio_ary_free(&ary);
Dynamic Hash Map Library: was designed to make Hash maps a breeze.
The following example uses
void * types for values and
uint64_t types for keys, but it's easy enough to use Strings or any other data type as keys:
// container on the stack (can also be placed on the heap). fio_hash_s hash = FIO_HASH_INIT; fio_hash_insert(&hash, 1, (void *)1); printf("Hash seek key %u => value: %zd", 1, fio_hash_find(&hash, 1)); printf("Hash seek key %u => value: %zd", 2, fio_hash_find(&hash, 2)); fio_hash_free(&ary); // use FIO_HASH_FOR_FREE to free object data or custom keys.
Linked Lists Library: was designed to make linked lists a breeze.
The library supports both flavors of linked lists, external (node contains a pointer) and embedded (nodes contain actual data).
The single header parser libraries often declare callbacks that should be defined (implemented) by the file that includes the library.
For example, the JSON parser expects the client to implement the
fio_json_on_null. The callbacks should be used to build the data structure that contains the results.
These single-file parsers include:
WebSockets parser: WebSockets are used for bi-directional communication across the web. Unlike raw TCP/IP, this added layer converts the communication scheme from streaming based communication to message based communication, preserving message boundaries. More details about WebSockets at websocket.org.
The following libraries consist of both a header and a source file that can be used independently.
Simply copy both files to your project and enjoy.
fio_mem library is a custom memory allocator that was designed for network use, minimizing lock contention and offering minimal allocation overhead.
I wrote it to solve an issue I had with memory fragmentation and race conditions during multi-threaded allocations.
The allocator doesn't return all the memory to the system. Instead, there's a memory pool that is retained, improving concurrency even across process borders by minimizing system calls.