Skip to content

Commit 4a5168e

Browse files
authored
Merge pull request #128 from KotzaBoss/cfe-3417/master
CFE-3417: Added strcmp wrapper to be used in sequence functions
2 parents bc67d9b + 9a33d2c commit 4a5168e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

libutils/sequence.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ static void ExpandIfNeccessary(Seq *seq)
9090
}
9191
}
9292

93+
int StrCmpWrapper(const void *s1, const void *s2, void *user_data)
94+
{
95+
UNUSED(user_data);
96+
return strcmp(s1, s2);
97+
}
98+
9399
void SeqSet(Seq *seq, size_t index, void *item)
94100
{
95101
assert(seq != NULL);

libutils/sequence.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ void SeqSoftDestroy(Seq *seq);
9999
*/
100100
typedef int (*SeqItemComparator) (const void *, const void *, void *user_data);
101101

102+
/**
103+
@brief Wrapper of the standard library function strcmp.
104+
Used to avoid cast-function-type compiler warnings when
105+
casting strcmp to (SeqItemComparator) in sequence functions.
106+
107+
@param [in] s1 The string being compared to the s2 string
108+
@param [in] s2 The string that s1 is compared to
109+
@param [in] user_data This parameter is the ignored user_data that the SeqItemComparator
110+
expects
111+
112+
@return 0 if s1 and s2 strings are equal
113+
@return negative if s1 is less than s2
114+
@return positive if s1 is greater than s2
115+
*/
116+
int StrCmpWrapper(const void *s1, const void *s2, void *user_data);
117+
102118
void SeqSet(Seq *set, size_t index, void *item);
103119

104120
/**

0 commit comments

Comments
 (0)