diff --git a/hashmap/myhashmap.h b/hashmap/myhashmap.h index 3826603..228c2ef 100644 --- a/hashmap/myhashmap.h +++ b/hashmap/myhashmap.h @@ -1,7 +1,7 @@ #ifndef MYCLIB_HASHMAP_H #define MYCLIB_HASHMAP_H -#include +#include #include #include @@ -13,11 +13,11 @@ * Each bucket can hold one key-value pair and points to the next bucket * in case of hash collisions (separate chaining). */ -typedef struct mcl_bucket_t { +typedef struct mcl_bucket { void *key; /**< Pointer to the key */ void *value; /**< Pointer to the value */ - struct mcl_bucket_t *next; /**< Pointer to the next bucket in case of collision */ -} mcl_bucket; + struct mcl_bucket *next; /**< Pointer to the next bucket in case of collision */ +} mcl_bucket_s; /** * @brief Function pointer type for a hash function diff --git a/string/mystring.c b/string/mystring.c index d15520e..5e73931 100644 --- a/string/mystring.c +++ b/string/mystring.c @@ -40,12 +40,12 @@ size_t mcl_next_power_two(size_t len) { return p; } -mcl_string *mcl_string_new(const char *text, size_t initial_capacity) { +mcl_string_s *mcl_string_new(const char *text, size_t initial_capacity) { if (text == NULL) { return NULL; } - mcl_string *str = malloc(sizeof(mcl_string)); + mcl_string_s *str = malloc(sizeof(mcl_string_s)); if (str == NULL) { return NULL; } @@ -88,7 +88,7 @@ mcl_string *mcl_string_new(const char *text, size_t initial_capacity) { return str; } -int mcl_string_append(mcl_string *string, const char *text) { +int mcl_string_append(mcl_string_s *string, const char *text) { if (string == NULL || text == NULL) { return -1; } @@ -133,7 +133,7 @@ int mcl_string_append(mcl_string *string, const char *text) { return 0; } -void mcl_string_free(mcl_string *string) { +void mcl_string_free(mcl_string_s *string) { if (string == NULL) { return; } @@ -147,7 +147,7 @@ void mcl_string_free(mcl_string *string) { free(string); } -size_t mcl_string_length(mcl_string *string) { +size_t mcl_string_length(mcl_string_s *string) { if (string == NULL) { return 0; } @@ -163,7 +163,7 @@ size_t mcl_string_length(mcl_string *string) { return len; } -size_t mcl_string_capacity(mcl_string *string) { +size_t mcl_string_capacity(mcl_string_s *string) { if (string == NULL) { return 0; } @@ -179,7 +179,7 @@ size_t mcl_string_capacity(mcl_string *string) { return cap; } -char *mcl_string_cstr(mcl_string *string) { +char *mcl_string_cstr(mcl_string_s *string) { if (string == NULL || string->data == NULL) { return NULL; } diff --git a/string/mystring.h b/string/mystring.h index a3cc57d..fba6f2d 100644 --- a/string/mystring.h +++ b/string/mystring.h @@ -12,7 +12,7 @@ typedef struct mcl_string { size_t size; /**< Current length of the string (excluding null terminator) */ size_t capacity; /**< Allocated capacity including null terminator */ mtx_t lock; /**< Mutex for thread safety */ -} mcl_string; +} mcl_string_s; /** * @brief Create a new string initialized with the given text. @@ -24,7 +24,7 @@ typedef struct mcl_string { * * @note Caller must release the string using mcl_string_free(). */ -mcl_string *mcl_string_new(const char *text, size_t initial_capacity); +mcl_string_s *mcl_string_new(const char *text, size_t initial_capacity); /** * @brief Append text to the string. @@ -35,7 +35,7 @@ mcl_string *mcl_string_new(const char *text, size_t initial_capacity); * * @note On failure, the original string remains unchanged. */ -int mcl_string_append(mcl_string *string, const char *text); +int mcl_string_append(mcl_string_s *string, const char *text); /** * @brief Free the string and its resources. @@ -44,7 +44,7 @@ int mcl_string_append(mcl_string *string, const char *text); * * @note Caller must ensure no other thread is concurrently using this mcl_string. */ -void mcl_string_free(mcl_string *string); +void mcl_string_free(mcl_string_s *string); /** * @brief Get the current length of the string. @@ -52,7 +52,7 @@ void mcl_string_free(mcl_string *string); * @param string String to query * @return Length of the string (excluding null terminator), or 0 if NULL */ -size_t mcl_string_length(mcl_string *string); +size_t mcl_string_length(mcl_string_s *string); /** * @brief Get the total allocated capacity of the string buffer. @@ -60,7 +60,7 @@ size_t mcl_string_length(mcl_string *string); * @param string String to query * @return Capacity (in bytes, including null terminator), or 0 if NULL */ -size_t mcl_string_capacity(mcl_string *string); +size_t mcl_string_capacity(mcl_string_s *string); /** * @brief Get a pointer to a null-terminated C-string representing the content. @@ -71,6 +71,6 @@ size_t mcl_string_capacity(mcl_string *string); * @note The returned pointer is valid until the next call to mcl_string_cstr() * in the same thread or until the thread exits. **Do NOT free** the returned pointer. */ -char *mcl_string_cstr(mcl_string *string); +char *mcl_string_cstr(mcl_string_s *string); #endif /* MYCLIB_STRING_H */