Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
e3445442
Commit
e3445442
authored
Oct 05, 2013
by
deuce
Browse files
Add strListDup() and strListCmp()
parent
6176d2ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
src/xpdev/str_list.c
src/xpdev/str_list.c
+41
-0
src/xpdev/str_list.h
src/xpdev/str_list.h
+6
-0
No files found.
src/xpdev/str_list.c
View file @
e3445442
...
...
@@ -379,6 +379,47 @@ void strListSortAlphaCaseReverse(str_list_t list)
qsort
(
list
,
strListCount
(
list
),
sizeof
(
char
*
),
strListCompareAlphaCaseReverse
);
}
str_list_t
strListDup
(
str_list_t
list
)
{
str_list_t
ret
;
size_t
count
=
0
;
ret
=
strListInit
();
for
(;
*
list
;
list
++
)
strListAppend
(
&
ret
,
*
list
,
count
++
);
return
ret
;
}
int
strListCmp
(
str_list_t
list1
,
str_list_t
list2
)
{
str_list_t
l1
=
strListDup
(
list1
);
str_list_t
l2
=
strListDup
(
list2
);
int
tmp
;
if
(
*
l1
==
NULL
&&
*
l2
==
NULL
)
return
0
;
if
(
*
l1
==
NULL
)
return
-
1
;
if
(
*
l2
==
NULL
)
return
1
;
strListSortAlphaCase
(
l1
);
strListSortAlphaCase
(
l2
);
for
(;
*
l1
;
l1
++
)
{
l2
++
;
if
(
*
l2
==
NULL
)
return
1
;
tmp
=
strcmp
(
*
l1
,
*
l2
);
if
(
tmp
!=
0
)
return
tmp
;
}
l2
++
;
if
(
*
l2
==
NULL
)
return
0
;
return
-
1
;
}
void
strListFreeStrings
(
str_list_t
list
)
{
size_t
i
;
...
...
src/xpdev/str_list.h
View file @
e3445442
...
...
@@ -125,6 +125,12 @@ char* strListAppendBlock(char* block, str_list_t);
size_t
strListBlockLength
(
char
*
block
);
void
strListFreeBlock
(
char
*
);
/* Duplicates a list */
str_list_t
strListDup
(
str_list_t
list
);
/* Compares two lists */
int
strListCmp
(
str_list_t
list1
,
str_list_t
list2
);
/************/
/* File I/O */
/************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment