Skip to content

dosart/Implementing-libc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implementing-libc

Codacy Badge Build Status

This is a simple libc implementation for educational purposes.

memory menager

  • void *malloc (unsigned long) - allocates size bytes of uninitialized storage
  • void *calloc(unsigned long) - allocates memory for an array of num objects of size size and initializes it to all bits zero
  • void *realoc(unsigned long) - reallocates the given area of memory
  • void free(void* ptr) - deallocates the space previously allocated by malloc(), calloc(), realoc()

tiny garbage collector

Implementation of Mark&Sweep algorithm for memory manager

simple smart pointers (I know it's not libc. Decided to practice memory management)

unique_ptr:

  • unique_ptr() - creates a unique_ptr that owns nothing
  • unique_ptr( std::nullptr_t ) - creates a unique_ptr that owns nothing
  • unique_ptr( pointer p ) - creates a unique_ptr that owns pointer
  • operator* - dereferences pointer to the managed object
  • operator-> - dereferences pointer to the managed object
  • operator bool - checks if there is an associated managed object
  • get() - returns a pointer to the managed object
  • release() - returns a pointer to the managed object and releases the ownership

string.h

  • void *memcpy(void *dest, const void *src, size_t n) - copies bytes between buffers. From src to dest
  • void *memset(void *buf, char ch, size_t count) - sets buffers to a specified character
  • char *cat(char *dest, const char *src) - appends a string
  • size_t len(const char *str) - gets the length of a string
  • char *cpy(char *dest, const char *src) - copies a string
  • char *cpyn(char *dest, const char *src, size_t num) - copies the first num characters of source to destination
  • size_t spn(const char *str, char *accept) - teturns the length of the initial portion of str1 which consists only of characters that are part of accept
  • size_t cspn(const char *str, char *not_accept) - Scans str1 for the first occurrence of any of the characters that are part of str2, returning the number of characters of str1 read before this first occurrence
  • char *ch(char *str, char ch) - returns a pointer to the first occurrence of character in the C string str

About

Implementation libc for education (just for fun)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published