From 3a80748d35b1e3b2ee75c7ff7ff48678a080d680 Mon Sep 17 00:00:00 2001 From: Alex Schneider Date: Mon, 30 Jan 2017 06:03:53 +0100 Subject: [PATCH 1/2] Using `typedef struct` for better code readability --- php_shmt.c | 132 ++++++++++++++++++++++++++--------------------------- shmt.c | 58 +++++++++++------------ shmt.h | 58 ++++++++++++----------- 3 files changed, 127 insertions(+), 121 deletions(-) diff --git a/php_shmt.c b/php_shmt.c index d37df6f..da2b5b6 100644 --- a/php_shmt.c +++ b/php_shmt.c @@ -69,18 +69,18 @@ PHP_METHOD(SHMT, __construct) } /* Assign the pointer to the right addresses/offsets */ - object->map = (struct _shmtHash *)((void *)object->shmt + sizeof(struct _shmtHead)); - object->tbl = (struct _shmtItem *)((void *)object->map + object->shmt->hashSize); + object->map = (shmtHash *)((void *)object->shmt + sizeof(shmtHead)); + object->tbl = (shmtItem *)((void *)object->map + object->shmt->hashSize); } PHP_METHOD(SHMT, get) { - shmt_object *object; - char *key; - size_t keyLen; - uint32_t hash; - struct _shmtItem *shmtItem; - struct _shmtHash *shmtHash; + shmt_object *object; + char *key; + size_t keyLen; + uint32_t hash; + shmtItem *pItem; + shmtHash *pHash; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &keyLen)) { return; @@ -91,20 +91,20 @@ PHP_METHOD(SHMT, get) /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ hash = shmtGetHash(key, keyLen, 0); - shmtHash = &object->map[hash & object->shmt->mask]; + pHash = &object->map[hash & object->shmt->mask]; - if (shmtHash->seed == UINT32_MAX) { + if (pHash->seed == UINT32_MAX) { /* Direct hit */ - shmtItem = &shmtHash->hit; + pItem = &pHash->hit; } else { /* Resolved item */ - hash = shmtGetHash(key, keyLen, shmtHash->seed); - shmtItem = &object->tbl[hash & object->shmt->mask]; + hash = shmtGetHash(key, keyLen, pHash->seed); + pItem = &object->tbl[hash & object->shmt->mask]; } - if ((shmtItem->key_pos != SIZE_MAX) && (keyLen == shmtItem->key_len)) { - if ((memcmp((const void *)((void *)object->shmt + shmtItem->key_pos), key, keyLen) == 0)) { - RETURN_STRINGL((void *)object->shmt + shmtItem->key_pos + shmtItem->key_len, shmtItem->val_len); + if ((pItem->key_pos != SIZE_MAX) && (keyLen == pItem->key_len)) { + if ((memcmp((const void *)((void *)object->shmt + pItem->key_pos), key, keyLen) == 0)) { + RETURN_STRINGL((void *)object->shmt + pItem->key_pos + pItem->key_len, pItem->val_len); } } @@ -116,16 +116,16 @@ PHP_METHOD(SHMT, get) PHP_METHOD(SHMT, create) { - char *path; - size_t pathLen; - zval *data, currKey, *currVal; - HashTable *htData; - HashPosition hpPos; - uint32_t iCount, iItemIndex, iterator = 0; - FILE *pFile; - struct _shmtHead shmtHead; - struct _shmtHash *pMap; - struct _shmtItem *pTbl, *shmtItem; + char *path; + size_t pathLen; + zval *data, currKey, *currVal; + HashTable *htData; + HashPosition hpPos; + uint32_t iCount, iItemIndex, iterator = 0; + FILE *pFile; + shmtHead sHead; + shmtHash *pMap; + shmtItem *pTbl, *pItem; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &path, &pathLen, &data)) { return; @@ -146,40 +146,40 @@ PHP_METHOD(SHMT, create) /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - shmtHead = shmtCreateHeader(iCount); + sHead = shmtCreateHeader(iCount); - if (shmtHead.mask == UINT32_MAX) { - return shmtCleanup(&shmtHead, NULL, pFile, path, NULL, NULL, "SHMT: Number of the given elements is out of range"); + if (sHead.mask == UINT32_MAX) { + return shmtCleanup(&sHead, NULL, pFile, path, NULL, NULL, "SHMT: Number of the given elements is out of range"); } - if ((fwrite(&shmtHead, 1, sizeof(shmtHead), pFile)) < sizeof(shmtHead)) { - return shmtCleanup(&shmtHead, NULL, pFile, path, NULL, NULL, "SHMT: Cannot write the header"); + if ((fwrite(&sHead, 1, sizeof(sHead), pFile)) < sizeof(sHead)) { + return shmtCleanup(&sHead, NULL, pFile, path, NULL, NULL, "SHMT: Cannot write the header"); } - if (!shmtCreateMapTable(&pMap, &pTbl, shmtHead)) { - return shmtCleanup(&shmtHead, NULL, pFile, path, NULL, NULL, "SHMT: Cannot create the table"); + if (!shmtCreateMapTable(&pMap, &pTbl, sHead)) { + return shmtCleanup(&sHead, NULL, pFile, path, NULL, NULL, "SHMT: Cannot create the table"); } - if (fseek(pFile, shmtHead.mapSize, SEEK_CUR)) { - return shmtCleanup(&shmtHead, pMap, pFile, path, NULL, NULL, "SHMT: Unexpected internal \"seek\" error"); + if (fseek(pFile, sHead.mapSize, SEEK_CUR)) { + return shmtCleanup(&sHead, pMap, pFile, path, NULL, NULL, "SHMT: Unexpected internal \"seek\" error"); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ uint32_t n, newHashVal, newHashMod, newSeed; - struct _shmtCreatorItem *pCItem = NULL, *pCItems = NULL; - struct _shmtCreatorList *pLItem = NULL, *pLItems = NULL; + shmtCreatorItem *pCItem = NULL, *pCItems = NULL; + shmtCreatorList *pLItem = NULL, *pLItems = NULL; - if ((pCItems = (struct _shmtCreatorItem *)emalloc((shmtHead.mask + 1) * sizeof(struct _shmtCreatorItem))) == NULL) { - return shmtCleanup(&shmtHead, pMap, pFile, path, NULL, NULL, "SHMT: Unexpected internal \"malloc\" error"); + if ((pCItems = (shmtCreatorItem *)emalloc((sHead.mask + 1) * sizeof(shmtCreatorItem))) == NULL) { + return shmtCleanup(&sHead, pMap, pFile, path, NULL, NULL, "SHMT: Unexpected internal \"malloc\" error"); } - if ((pLItems = (struct _shmtCreatorList *)emalloc((shmtHead.mask + 1) * sizeof(struct _shmtCreatorList))) == NULL) { - return shmtCleanup(&shmtHead, pMap, pFile, path, pCItems, NULL, "SHMT: Unexpected internal \"malloc\" error"); + if ((pLItems = (shmtCreatorList *)emalloc((sHead.mask + 1) * sizeof(shmtCreatorList))) == NULL) { + return shmtCleanup(&sHead, pMap, pFile, path, pCItems, NULL, "SHMT: Unexpected internal \"malloc\" error"); } - memset(pCItems, 0, (shmtHead.mask + 1) * sizeof(struct _shmtCreatorItem)); - memset(pLItems, 0, (shmtHead.mask + 1) * sizeof(struct _shmtCreatorList)); + memset(pCItems, 0, (sHead.mask + 1) * sizeof(shmtCreatorItem)); + memset(pLItems, 0, (sHead.mask + 1) * sizeof(shmtCreatorList)); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -190,17 +190,17 @@ PHP_METHOD(SHMT, create) convert_to_string(&currKey); iItemIndex = iterator++; - pCItem = ((struct _shmtCreatorItem *)(pCItems)) + iItemIndex; + pCItem = ((shmtCreatorItem *)(pCItems)) + iItemIndex; pCItem->hash = shmtGetHash(Z_STRVAL(currKey), Z_STRLEN(currKey), 0); - pCItem->hash = (uint32_t)(pCItem->hash & shmtHead.mask); + pCItem->hash = (uint32_t)(pCItem->hash & sHead.mask); pCItem->key = estrndup(Z_STRVAL(currKey), Z_STRLEN(currKey)); pCItem->key_len = Z_STRLEN(currKey); pCItem->val = estrndup(Z_STRVAL_P(currVal), Z_STRLEN_P(currVal)); pCItem->val_len = Z_STRLEN_P(currVal); - pLItem = ((struct _shmtCreatorList *)(pLItems)) + pCItem->hash; + pLItem = ((shmtCreatorList *)(pLItems)) + pCItem->hash; if (!pLItem->num) { pLItem->idx = UINT32_MAX; @@ -216,10 +216,10 @@ PHP_METHOD(SHMT, create) /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - qsort((void *)pLItems, shmtHead.mask + 1, sizeof(struct _shmtCreatorList), shmtSortCmp); + qsort((void *)pLItems, sHead.mask + 1, sizeof(shmtCreatorList), shmtSortCmp); - for (iterator = 0; iterator <= shmtHead.mask; iterator++) { - pLItem = ((struct _shmtCreatorList *)(pLItems)) + iterator; + for (iterator = 0; iterator <= sHead.mask; iterator++) { + pLItem = ((shmtCreatorList *)(pLItems)) + iterator; /* Ready, all items are written. */ if (pLItem->num <= 0) { @@ -237,14 +237,14 @@ PHP_METHOD(SHMT, create) memset(&aTempMod, UINT32_MAX, sizeof(aTempMod)); while (iItemIndex != UINT32_MAX) { - pCItem = ((struct _shmtCreatorItem *)(pCItems)) + iItemIndex; + pCItem = ((shmtCreatorItem *)(pCItems)) + iItemIndex; newHashVal = shmtGetHash(pCItem->key, pCItem->key_len, newSeed); - newHashMod = newHashVal & shmtHead.mask; + newHashMod = newHashVal & sHead.mask; - shmtItem = ((struct _shmtItem *)(pTbl)) + newHashMod; + pItem = ((shmtItem *)(pTbl)) + newHashMod; - if (shmtItem->key_pos != SIZE_MAX) { + if (pItem->key_pos != SIZE_MAX) { newSeed++; memset(&aTempMod, UINT32_MAX, sizeof(aTempMod)); iItemIndex = pLItem->idx; @@ -273,43 +273,43 @@ PHP_METHOD(SHMT, create) iItemIndex = pLItem->idx; for (n = 0; n < pLItem->num; n++) { - pCItem = ((struct _shmtCreatorItem *)(pCItems)) + iItemIndex; - shmtItem = ((struct _shmtItem *)(pTbl)) + aTempMod[n]; + pCItem = ((shmtCreatorItem *)(pCItems)) + iItemIndex; + pItem = ((shmtItem *)(pTbl)) + aTempMod[n]; - if (!shmtWriteItem(pCItem, shmtItem, pFile)) { - return shmtCleanup(&shmtHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Unexpected internal \"write\" error"); + if (!shmtWriteItem(pCItem, pItem, pFile)) { + return shmtCleanup(&sHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Unexpected internal \"write\" error"); } iItemIndex = pCItem->next; } } else { /* Collision free items are written directly into the pMap (not pTbl) array. */ - pCItem = ((struct _shmtCreatorItem *)(pCItems)) + iItemIndex; + pCItem = ((shmtCreatorItem *)(pCItems)) + iItemIndex; if (!shmtWriteItem(pCItem, &pMap[pCItem->hash].hit, pFile)) { - return shmtCleanup(&shmtHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Unexpected internal \"write\" error"); + return shmtCleanup(&sHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Unexpected internal \"write\" error"); } } } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - if (fseek(pFile, sizeof(shmtHead), SEEK_SET) || ((fwrite(pMap, 1, shmtHead.mapSize, pFile)) < shmtHead.mapSize)) { - return shmtCleanup(&shmtHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Cannot write the table"); + if (fseek(pFile, sizeof(sHead), SEEK_SET) || ((fwrite(pMap, 1, sHead.mapSize, pFile)) < sHead.mapSize)) { + return shmtCleanup(&sHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Cannot write the table"); } if ( (fseek(pFile, 0, SEEK_END) != 0) || - ((shmtHead.fileSize = ftell(pFile)) <= 0) || - (fseek(pFile, (void *)&shmtHead.fileSize - (void *)&shmtHead, SEEK_SET) != 0) || - ((fwrite(&shmtHead.fileSize, 1, sizeof(shmtHead.fileSize), pFile)) < sizeof(shmtHead.fileSize)) + ((sHead.fileSize = ftell(pFile)) <= 0) || + (fseek(pFile, (void *)&sHead.fileSize - (void *)&sHead, SEEK_SET) != 0) || + ((fwrite(&sHead.fileSize, 1, sizeof(sHead.fileSize), pFile)) < sizeof(sHead.fileSize)) ) { - return shmtCleanup(&shmtHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Unexpected internal \"finalize\" error"); + return shmtCleanup(&sHead, pMap, pFile, path, pCItems, pLItems, "SHMT: Unexpected internal \"finalize\" error"); } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - shmtCleanup(&shmtHead, pMap, pFile, NULL, pCItems, pLItems, NULL); + shmtCleanup(&sHead, pMap, pFile, NULL, pCItems, pLItems, NULL); RETURN_TRUE; } diff --git a/shmt.c b/shmt.c index b17a897..bf2e012 100644 --- a/shmt.c +++ b/shmt.c @@ -9,39 +9,39 @@ /* ==================================================================================================== */ -struct _shmtHead shmtCreateHeader(uint32_t size) +shmtHead shmtCreateHeader(uint32_t size) { - struct _shmtHead shmtHead; + shmtHead sHead; - memset(&shmtHead, 0, sizeof(struct _shmtHead)); + memset(&sHead, 0, sizeof(sHead)); - shmtHead.mark = SHMT_MARK; - shmtHead.version = SHMT_FILE_VERSION; - shmtHead.system = SIZEOF_SIZE_T; - shmtHead.mask = _shmtGetMapSize(size) - 1; - shmtHead.fileSize = 0; - shmtHead.hashSize = (shmtHead.mask + 1) * sizeof(struct _shmtHash); - shmtHead.mapSize = shmtHead.hashSize + ((shmtHead.mask + 1) * sizeof(struct _shmtItem)); + sHead.mark = SHMT_MARK; + sHead.version = SHMT_FILE_VERSION; + sHead.system = SIZEOF_SIZE_T; + sHead.mask = _shmtGetMapSize(size) - 1; + sHead.fileSize = 0; + sHead.hashSize = (sHead.mask + 1) * sizeof(shmtHash); + sHead.mapSize = sHead.hashSize + ((sHead.mask + 1) * sizeof(shmtItem)); - return shmtHead; + return sHead; } -int shmtCreateMapTable(struct _shmtHash **pMap, struct _shmtItem **pTbl, struct _shmtHead shmtHead) +int shmtCreateMapTable(shmtHash **pMap, shmtItem **pTbl, shmtHead sHead) { - if ((*pMap = (struct _shmtHash *)emalloc(shmtHead.mapSize)) == NULL) { + if ((*pMap = (shmtHash *)emalloc(sHead.mapSize)) == NULL) { return 0; } /* Fill the pMap and pTbl with the empty-index flags */ - memset(((void *)(*pMap)), UINT32_MAX, shmtHead.mapSize); + memset(((void *)(*pMap)), UINT32_MAX, sHead.mapSize); /* Assign the forwarded address */ - *pTbl = (struct _shmtItem *)((void *)*pMap + shmtHead.hashSize); + *pTbl = (shmtItem *)((void *)*pMap + sHead.hashSize); return 1; } -int shmtWriteItem(struct _shmtCreatorItem *src, struct _shmtItem *shmtItem, FILE *file) +int shmtWriteItem(shmtCreatorItem *src, shmtItem *shmtItem, FILE *file) { if ((shmtItem->key_pos = ftell(file)) <= 0) { return 0; @@ -71,7 +71,7 @@ int shmtWriteItem(struct _shmtCreatorItem *src, struct _shmtItem *shmtItem, FILE return 1; } -int shmtReadTable(const char *path, struct _shmtHead **shmt) +int shmtReadTable(const char *path, shmtHead **shmt) { struct stat sizeCheck; int file; @@ -84,9 +84,9 @@ int shmtReadTable(const char *path, struct _shmtHead **shmt) return shmtCleanupReader(file, "SHMT: Cannot read the file size"); } else if ((size_t)sizeCheck.st_size > SIZE_MAX) { return shmtCleanupReader(file, "SHMT: Given file is out of the supported file size range"); - } else if ((size_t)sizeCheck.st_size < sizeof(struct _shmtHead)) { + } else if ((size_t)sizeCheck.st_size < sizeof(shmtHead)) { return shmtCleanupReader(file, "SHMT: Cannot read the header"); - } else if ((*shmt = (struct _shmtHead *)mmap(NULL, (size_t)sizeCheck.st_size, PROT_READ, MAP_SHARED, file, 0)) == MAP_FAILED) { + } else if ((*shmt = (shmtHead *)mmap(NULL, (size_t)sizeCheck.st_size, PROT_READ, MAP_SHARED, file, 0)) == MAP_FAILED) { return shmtCleanupReader(file, "SHMT: Cannot map the file to the memory"); } else if ((size_t)sizeCheck.st_size != (*shmt)->fileSize) { return shmtCleanupReader(file, "SHMT: Corrupt SHMT file detected"); @@ -115,11 +115,11 @@ int shmtCleanupReader(int file, const char *message) return 1; } -void shmtCleanup(struct _shmtHead *head, struct _shmtHash *map, FILE *file, const char *path, struct _shmtCreatorItem *it, struct _shmtCreatorList *li, const char *message) +void shmtCleanup(shmtHead *sHead, shmtHash *map, FILE *file, const char *path, shmtCreatorItem *it, shmtCreatorList *li, const char *message) { - struct _shmtCreatorList *pLItem; - struct _shmtCreatorItem *pCItem; - size_t idx, iterator; + shmtCreatorList *pLItem; + shmtCreatorItem *pCItem; + size_t idx, iterator; if (map != NULL) { efree(map); @@ -134,9 +134,9 @@ void shmtCleanup(struct _shmtHead *head, struct _shmtHash *map, FILE *file, cons } if (it != NULL) { - if ((li != NULL) && (head != NULL)) { - for (iterator = 0; iterator <= head->mask; iterator++) { - pLItem = ((struct _shmtCreatorList *)li) + iterator; + if ((li != NULL) && (sHead != NULL)) { + for (iterator = 0; iterator <= sHead->mask; iterator++) { + pLItem = ((shmtCreatorList *)li) + iterator; if (pLItem->num <= 0) { break; /* No more items available, nothing to free any more */ @@ -146,7 +146,7 @@ void shmtCleanup(struct _shmtHead *head, struct _shmtHash *map, FILE *file, cons if (pLItem->num > 1) { while (idx != UINT32_MAX) { - pCItem = ((struct _shmtCreatorItem *)it) + idx; + pCItem = ((shmtCreatorItem *)it) + idx; efree(pCItem->key); efree(pCItem->val); @@ -154,7 +154,7 @@ void shmtCleanup(struct _shmtHead *head, struct _shmtHash *map, FILE *file, cons idx = pCItem->next; } } else { - pCItem = ((struct _shmtCreatorItem *)it) + idx; + pCItem = ((shmtCreatorItem *)it) + idx; efree(pCItem->key); efree(pCItem->val); @@ -174,7 +174,7 @@ void shmtCleanup(struct _shmtHead *head, struct _shmtHash *map, FILE *file, cons } } -void shmtFree(struct _shmtHead *shmt) +void shmtFree(shmtHead *shmt) { if (shmt && (shmt != MAP_FAILED)) { munmap(shmt, shmt->fileSize); diff --git a/shmt.h b/shmt.h index a4da63d..19b0ad7 100644 --- a/shmt.h +++ b/shmt.h @@ -20,6 +20,12 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* STRUCTURES */ + typedef struct _shmtCreatorItem shmtCreatorItem; + typedef struct _shmtCreatorList shmtCreatorList; + typedef struct _shmtItem shmtItem; + typedef struct _shmtHash shmtHash; + typedef struct _shmtHead shmtHead; + struct _shmtCreatorItem { char *key; @@ -32,58 +38,58 @@ struct _shmtCreatorList { - uint32_t num; /* The number of items in the current bucket */ - uint32_t idx; /* The index of the last item in the current bucket */ + uint32_t num; /* The number of items in the current bucket */ + uint32_t idx; /* The index of the last item in the current bucket */ }; struct _shmtItem { - size_t key_pos; /* The offset to the key string */ - uint32_t key_len; /* The key string length */ - uint32_t val_len; /* The value string length */ + size_t key_pos; /* The offset to the key string */ + uint32_t key_len; /* The key string length */ + uint32_t val_len; /* The value string length */ }; struct _shmtHash { - uint32_t seed; /* The alternative seed */ - struct _shmtItem hit; /* The direct hit */ + uint32_t seed; /* The alternative seed */ + shmtItem hit; /* The direct hit */ }; struct _shmtHead { - uint32_t mark; /* The plausibility check mark */ - uint16_t version; /* The file compatibility check mark */ - uint8_t system; /* The system compatibility check mark (32/64 bit) */ - uint32_t mask; /* The hash map mask */ - size_t mapSize; /* The total hash map table size */ - size_t hashSize; /* The size of the "hash" part in the hash map */ - size_t fileSize; /* The file size in bytes (for "mmap()") */ + uint32_t mark; /* The plausibility check mark */ + uint16_t version; /* The file compatibility check mark */ + uint8_t system; /* The system compatibility check mark (32/64 bit) */ + uint32_t mask; /* The hash map mask */ + size_t mapSize; /* The total hash map table size */ + size_t hashSize; /* The size of the "hash" part in the hash map */ + size_t fileSize; /* The file size in bytes (for "mmap()") */ }; typedef struct _shmt_object { - struct _shmtHead *shmt; /* The "mmap()" pointer to be able to call "munmap()" */ - struct _shmtHash *map; /* The pointer to the "map" part in the total map table */ - struct _shmtItem *tbl; /* The pointer to the "tbl" part in the total map table */ - zend_object std; /* The PHP class object */ + shmtHead *shmt; /* The "mmap()" pointer to be able to call "munmap()" */ + shmtHash *map; /* The pointer to the "map" part in the total map table */ + shmtItem *tbl; /* The pointer to the "tbl" part in the total map table */ + zend_object std; /* The PHP class object */ } shmt_object; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* FUNCTIONS */ - struct _shmtHead shmtCreateHeader(uint32_t size); + shmtHead shmtCreateHeader(uint32_t size); - int shmtCreateMapTable(struct _shmtHash **pMap, struct _shmtItem **pTbl, struct _shmtHead shmtHead); + int shmtCreateMapTable(shmtHash **pMap, shmtItem **pTbl, shmtHead shmtHead); - int shmtWriteItem(struct _shmtCreatorItem *src, struct _shmtItem *dest, FILE *file); + int shmtWriteItem(shmtCreatorItem *src, shmtItem *dest, FILE *file); - int shmtReadTable(const char *path, struct _shmtHead **shmt); + int shmtReadTable(const char *path, shmtHead **shmt); int shmtCleanupReader(int file, const char *message); - void shmtCleanup(struct _shmtHead *head, struct _shmtHash *map, FILE *file, const char *path, struct _shmtCreatorItem *it, struct _shmtCreatorList *li, const char *message); + void shmtCleanup(shmtHead *sHead, shmtHash *map, FILE *file, const char *path, shmtCreatorItem *it, shmtCreatorList *li, const char *message); - void shmtFree(struct _shmtHead *shmt); + void shmtFree(shmtHead *shmt); uint32_t _shmtGetMapSize(uint32_t size); @@ -91,9 +97,9 @@ static inline int shmtSortCmp(const void *a, const void *b) { - if ((*(struct _shmtCreatorList *)a).num > (*(struct _shmtCreatorList *)b).num) { + if ((*(shmtCreatorList *)a).num > (*(shmtCreatorList *)b).num) { return -1; - } else if ((*(struct _shmtCreatorList *)a).num < (*(struct _shmtCreatorList *)b).num) { + } else if ((*(shmtCreatorList *)a).num < (*(shmtCreatorList *)b).num) { return 1; } else { return 0; From 46ba3a358f46588c4015395badce42b51f215ff3 Mon Sep 17 00:00:00 2001 From: Alex Schneider Date: Mon, 30 Jan 2017 06:04:56 +0100 Subject: [PATCH 2/2] Update the `Changelog.md` --- Changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changelog.md b/Changelog.md index 9cc594a..d88e072 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ +1.0.2dev + + * Improved: Using `typedef struct` for better code readability (`3a80748`) + 1.0.1 * Fixed: Memory leaks in the `SHMT::create()` method (`7ea1490`)