libqaeda

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

mem.h (1447B)


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