Skip to content

momoyon/commonlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

115 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commonlib.h

Standard Library for C

Prefix

All functions/variables/macros/structs have the prefix c_/C_ to them. If you know their won't be any name collisions if you remove them, you can do so by defining COMMONLIB_REMOVE_PREFIX before including the header like:

#define COMMONLIB_REMOVE_PREFIX
#include <commonlib.h>

Type-defs

C type typedef
unsigned int uint
uint8_t uint8
uint16_t uint16
uint32_t uint32
uint64_t uint64
int8_t int8
int16_t int16
int32_t int32
int64_t int64
float float32
double float64
wchar_t wchar
const char* cstr
const wchar* wstr

Dynamic array

Dynamic array functions are implemented using macros and except a struct of your own with like:

typedef struct {
   <item-type> *items;
   size_t count;
   size_t capacity;
   [extra fields...];
}

Operations on dynamic arrays:

  • c_darr_append(da, elm)

Appends the element elm to the dynamic array da

  • c_darr_shift(da)

Shifts the elements of the dynamic array da to the left by one

Warning

c_darr_shift will make the da loose its ptr, so store the ptr elsewhere if you want to free it later!!!

  • c_darr_delete(da, type, idx)

Deletes the element at index idx from the dynamic array da; type is needed because we swap the element with the last element in the array (SEE IMPLEMENTATION FOR MORE INFO).

  • c_darr_remove(da, type, elm_ptr, idx)

Same as c_darr_delete() but user can provide a pointer elm_ptr that will be filled with the removed element.

WIP: Documentation

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages