C dynamic string library
C Makefile Shell
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Micro Strings

The Micro String library, hereinafter referred to as ustring, is a simple and small dynamic string libray for C that provides a dynamic string model similar to the Rust programming language. The two main data structures provided by ustring are the Ustring and Ustr. Ustring is similar to the String type in Rust, providing a region of memory that contains metadata about the string length and total size allocated to the string, including memory not in use. Ustr is similar to the str type in rust, and are usually used to point to another Ustr or Ustring's memory and only contain metadata about the length of the string.


Ustring s = {0};
Ustr slice = {0};

/* Create a new Ustring */
ustr_cat_cstr(&s, "Hello, world!");

/* Create a Ustr slice from a Ustring */
ustr_slice(&slice, USTR(s), 0, s.len);

/* Concatenate and Insert characters into a Ustring */
ustr_cat_cstr(&s, " This is Micro String!");

/* See the results! */
printf("%.*s\n", (int)slice.len, slice.mem);
printf("%s\n", s.mem);

Building & Installation

For users

Once you have the source code on your machine, build it by running the following command:

make all

Then, once the library is built, it can be installed when you have root permissions with:

make install

For developers

To build and run the library tests, the following command should be run:

make test

These tests can then be run with:

make check