Skip to content

Commit 20abb19

Browse files
committed
fix(util): the preset dict types are not exported correctly
1 parent 6d54685 commit 20abb19

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

include/LCUI/util/dict.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,15 @@ LCUI_API int Dict_RehashMilliseconds(Dict *d, int ms);
238238
LCUI_API void Dict_SetHashFunctionSeed(unsigned int initval);
239239
LCUI_API unsigned int Dict_GetHashFunctionSeed(void);
240240

241+
LCUI_API unsigned int StringKeyDict_KeyHash(const void *key);
242+
LCUI_API int StringKeyDict_KeyCompare(void *privdata, const void *key1,
243+
const void *key2);
244+
LCUI_API void *StringKeyDict_KeyDup(void *privdata, const void *key);
245+
LCUI_API void StringKeyDict_KeyDestructor(void *privdata, void *key);
246+
241247
/* Hash table types */
242-
extern DictType DictType_StringKey;
243-
extern DictType DictType_StringCopyKey;
248+
LCUI_API DictType DictType_StringKey;
249+
LCUI_API DictType DictType_StringCopyKey;
244250

245251
LCUI_END_HEADER
246252

include/LCUI_Build.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
#define LCUI_BUILD_H
3333

3434
#if defined(__GNUC__)
35-
#define LCUI_API
36-
#else /* newer compiler */
35+
#define LCUI_API extern
36+
#else
3737
#ifdef LCUI_EXPORTS
3838
#define LCUI_API __declspec(dllexport)
3939
#else
40-
#define LCUI_API
40+
#define LCUI_API __declspec(dllimport)
41+
#endif
4142
#endif
42-
#endif /* compiler */
4343

4444
#if defined(_WIN32) && !defined(__cplusplus)
4545
#define INLINE __inline

src/util/dict.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void Dict_DisableResize(void)
679679
dict_can_resize = 0;
680680
}
681681

682-
static unsigned int StringCopyKeyDict_KeyHash(const void *key)
682+
unsigned int StringKeyDict_KeyHash(const void *key)
683683
{
684684
const char *buf = key;
685685
unsigned int hash = dict_hash_function_seed;
@@ -689,7 +689,7 @@ static unsigned int StringCopyKeyDict_KeyHash(const void *key)
689689
return hash;
690690
}
691691

692-
static int StringCopyKeyDict_KeyCompare(void *privdata, const void *key1,
692+
int StringKeyDict_KeyCompare(void *privdata, const void *key1,
693693
const void *key2)
694694
{
695695
if (strcmp(key1, key2) == 0) {
@@ -698,22 +698,22 @@ static int StringCopyKeyDict_KeyCompare(void *privdata, const void *key1,
698698
return 0;
699699
}
700700

701-
static void *StringCopyKeyDict_KeyDup(void *privdata, const void *key)
701+
void *StringKeyDict_KeyDup(void *privdata, const void *key)
702702
{
703703
char *newkey = malloc((strlen(key) + 1) * sizeof(char));
704704
strcpy(newkey, key);
705705
return newkey;
706706
}
707707

708-
static void StringCopyKeyDict_KeyDestructor(void *privdata, void *key)
708+
void StringKeyDict_KeyDestructor(void *privdata, void *key)
709709
{
710710
free(key);
711711
}
712712

713-
DictType DictType_StringKey = { StringCopyKeyDict_KeyHash, NULL, NULL,
714-
StringCopyKeyDict_KeyCompare, NULL, NULL };
713+
DictType DictType_StringKey = { StringKeyDict_KeyHash, NULL, NULL,
714+
StringKeyDict_KeyCompare, NULL, NULL };
715715

716716
DictType DictType_StringCopyKey = {
717-
StringCopyKeyDict_KeyHash, StringCopyKeyDict_KeyDup, NULL,
718-
StringCopyKeyDict_KeyCompare, StringCopyKeyDict_KeyDestructor, NULL
717+
StringKeyDict_KeyHash, StringKeyDict_KeyDup, NULL,
718+
StringKeyDict_KeyCompare, StringKeyDict_KeyDestructor, NULL
719719
};

0 commit comments

Comments
 (0)