Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
cc34d918
Commit
cc34d918
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Fixed the strListInsert() routines.
Added strListRemove() , to remove a single string from a string list.
parent
2b2762b8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/str_list.c
+28
-2
28 additions, 2 deletions
src/xpdev/str_list.c
src/xpdev/str_list.h
+6
-3
6 additions, 3 deletions
src/xpdev/str_list.h
with
34 additions
and
5 deletions
src/xpdev/str_list.c
+
28
−
2
View file @
cc34d918
...
...
@@ -85,17 +85,43 @@ static str_list_t str_list_insert(str_list_t* list, char* str, size_t index)
str_list_t
lp
;
count
=
strListCount
(
*
list
);
if
(
index
>
count
)
/* invalid index, do nothing */
return
(
NULL
);
count
++
;
if
((
lp
=
(
str_list_t
)
realloc
(
*
list
,
sizeof
(
char
*
)
*
(
count
+
1
)))
==
NULL
)
return
(
NULL
);
*
list
=
lp
;
for
(
i
=
index
;
i
<=
count
;
i
++
)
lp
[
i
+
1
]
=
lp
[
i
];
for
(
i
=
count
;
i
>
index
;
i
--
)
lp
[
i
]
=
lp
[
i
-
1
];
lp
[
index
]
=
str
;
return
(
lp
);
}
str_list_t
strListRemove
(
str_list_t
*
list
,
size_t
index
)
{
size_t
i
;
size_t
count
;
str_list_t
lp
;
count
=
strListCount
(
*
list
);
if
(
index
>=
count
)
/* invalid index, do nothing */
return
(
NULL
);
count
--
;
if
((
lp
=
(
str_list_t
)
realloc
(
*
list
,
sizeof
(
char
*
)
*
(
count
+
1
)))
==
NULL
)
return
(
NULL
);
*
list
=
lp
;
for
(
i
=
index
;
i
<
count
;
i
++
)
lp
[
i
]
=
lp
[
i
+
1
];
lp
[
count
]
=
NULL
;
return
(
lp
);
}
str_list_t
strListAddAt
(
str_list_t
*
list
,
const
char
*
str
,
size_t
count
)
{
char
*
buf
;
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/str_list.h
+
6
−
3
View file @
cc34d918
...
...
@@ -55,22 +55,25 @@ void strListFree(str_list_t* list);
/* Frees the strings in the list */
void
strListFreeStrings
(
str_list_t
list
);
/* Pass a pointer to a string list, the string to add */
/* Pass a pointer to a string list, the string to add
(append)
*/
/* Returns the updated list or NULL on error */
str_list_t
strListAdd
(
str_list_t
*
list
,
const
char
*
str
);
/* Adds a string into the list at a specific index */
str_list_t
strListAddAt
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
);
/* Append a string list onto
an
another string list */
/* Append a string list onto another string list */
str_list_t
strListAddList
(
str_list_t
*
list
,
const
str_list_t
append_list
);
/* Inserts a string into the list at a specific index */
str_list_t
strListInsert
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
);
/* Insert a string list
o
nto
an
another string list */
/* Insert a string list
i
nto another string list */
str_list_t
strListInsertList
(
str_list_t
*
list
,
const
str_list_t
append_list
,
size_t
index
);
/* Remove a string at a specific index */
str_list_t
strListRemove
(
str_list_t
*
list
,
size_t
index
);
/* Add to an exiting or new string list by splitting specified string (str) */
/* into multiple strings, separated by one of the delimit characters */
str_list_t
strListSplit
(
str_list_t
*
list
,
char
*
str
,
const
char
*
delimit
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment