libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

mem.h (1388B)


      1 #ifndef LIBQAEDA_MEM_H_
      2 #define LIBQAEDA_MEM_H_
      3 
      4 
      5 #include <stddef.h>
      6 
      7 
      8 /**
      9  * @brief Allocate heap memory.
     10  *
     11  * @param[in] Number of memory bytes to allocate.
     12  * @return Pointer to allocated memory. Returns NULL if allocation has failed.
     13  */
     14 void* lq_alloc(size_t bytes);
     15 
     16 /**
     17  * @brief Free a memory pointer.
     18  *
     19  * @param[in] Pointer to free.
     20  */
     21 void lq_free(void *o);
     22 
     23 /**
     24  * @brief Copy memory region.
     25  *
     26  * @param[out] Destination memory.
     27  * @param[in] Source memory.
     28  * @param[in] Number of bytes to copy.
     29  * @return Pointer to written memory.
     30  */
     31 void* lq_cpy(void *dst, const void *src, size_t len);
     32 
     33 /**
     34  *
     35  * @brief Fill memory region with value.
     36  *
     37  * @param[out] Destination memory.
     38  * @param[in] Value to write.
     39  * @param[in] Number of bytes to write.
     40  * @return Pointer to written memory.
     41  */
     42 void* lq_set(void *dst, const char b, size_t len);
     43 
     44 /**
     45  * @brief Fill memory region zeros.
     46  *
     47  * @param[out] Destination memory.
     48  * @param[in] Number of bytes to write.
     49  * @return Pointer to written memory.
     50  */
     51 void* lq_zero(void *dst, size_t len);
     52 
     53 /**
     54  * @brief Compare two memory regions
     55  *
     56  * @param[in] First memory region to compare.
     57  * @param[in] Second memory region to compare.
     58  * @param[in] Size of memory region to compare, in bytes. 
     59  * @return 0 if identical, -1 if dst < src
     60  */
     61 int lq_cmp(const void *dst, const void *src, size_t len);
     62 
     63 #endif // LIBQAEDA_MEM_H_