Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ def MatchingFor(*versions):
"objects": [
Object(Matching, "libms/commonlib.c"),
Object(Matching, "libms/flowfile.c"),
Object(NonMatching, "libms/libms.c"),
Object(Matching, "libms/libms.c"),
Object(Matching, "libms/msgfile.c"),
],
},
Expand Down
4 changes: 2 additions & 2 deletions include/libms/libms.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ void LMS_SetMemFuncs(void *(*alloc)(size_t size), void (*free)(void *ptr));
// internal
void *LMSi_Malloc(size_t size);
void LMSi_Free(void *ptr);
int LMSi_MemCmp(const char *p1, const char *p2, int n);
void LMSi_MemCopy(char *p1, const char *p2, int n);
int LMSi_MemCmp(const void *p1, const void *p2, int n);
void LMSi_MemCopy(void *p1, const void *p2, int n);

#ifdef __cplusplus
}
Expand Down
11 changes: 4 additions & 7 deletions src/libms/libms.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ void LMSi_Free(void *ptr) {
return (MSB_FREE_FUNC)(ptr);
}

int LMSi_MemCmp(const char *p1, const char *p2, int n) {
int LMSi_MemCmp(const void *p1, const void *p2, int n) {
for (int i = 0; i < n; i++) {
if (p1[i] != p2[i]) {
if (((const char *)p1)[i] != ((const char *)p2)[i]) {
return 0;
}
}

return 1;
}

void LMSi_MemCopy(char *p1, const char *p2, int n) {
// https://decomp.me/scratch/JOWiM
// NONMATCHING - register usage too optimal
// Look, how difficult can an unrolled memcopy be to match
void LMSi_MemCopy(void *p1, const void *p2, int n) {
for (int i = 0; i < n; i++) {
*(p1++) = *(p2++);
((char *)p1)[i] = ((const char *)p2)[i];
}
}
6 changes: 3 additions & 3 deletions src/libms/msgfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ int LMS_GetTextIndexByLabel(struct MsbtInfo *info, const char *label) {
int entryLen;
int sectionIndex;
int labelLen;
sectionIndex = info->lbl1Index;

sectionIndex = info->lbl1Index;
labelLen = 0;
if (info->lbl1Index == -1) {
return LMS_MISSING_LBL1_DATA;
Expand Down Expand Up @@ -73,7 +73,7 @@ const wchar_t *LMS_GetText(struct MsbtInfo *info, int index) {
return NULL;
}

return LMS_OFS_TO_PTR(const wchar_t , header, header[index + 1]);
return LMS_OFS_TO_PTR(const wchar_t, header, header[index + 1]);
}

const wchar_t *LMS_GetTextByLabel(struct MsbtInfo *info, const char *label) {
Expand Down