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
2b2762b8
Commit
2b2762b8
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created strListInsert() and strListInsertList().
parent
93c17909
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
+47
-8
47 additions, 8 deletions
src/xpdev/str_list.c
src/xpdev/str_list.h
+8
-2
8 additions, 2 deletions
src/xpdev/str_list.h
with
55 additions
and
10 deletions
src/xpdev/str_list.c
+
47
−
8
View file @
2b2762b8
...
...
@@ -64,16 +64,34 @@ size_t strListCount(const str_list_t list)
return
(
i
);
}
static
str_list_t
str_list_a
dd_at
(
str_list_t
*
list
,
char
*
str
,
size_t
count
)
static
str_list_t
str_list_a
ppend
(
str_list_t
*
list
,
char
*
str
,
size_t
index
)
{
str_list_t
lp
;
if
((
lp
=
(
str_list_t
)
realloc
(
*
list
,
sizeof
(
char
*
)
*
(
count
+
2
)))
==
NULL
)
if
((
lp
=
(
str_list_t
)
realloc
(
*
list
,
sizeof
(
char
*
)
*
(
index
+
2
)))
==
NULL
)
return
(
NULL
);
*
list
=
lp
;
lp
[
count
++
]
=
str
;
lp
[
count
]
=
NULL
;
/* terminate list */
lp
[
index
++
]
=
str
;
lp
[
index
]
=
NULL
;
/* terminate list */
return
(
lp
);
}
static
str_list_t
str_list_insert
(
str_list_t
*
list
,
char
*
str
,
size_t
index
)
{
size_t
i
;
size_t
count
;
str_list_t
lp
;
count
=
strListCount
(
*
list
);
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
];
lp
[
index
]
=
str
;
return
(
lp
);
}
...
...
@@ -87,16 +105,15 @@ str_list_t strListAddAt(str_list_t* list, const char* str, size_t count)
strcpy
(
buf
,
str
);
return
(
str_list_a
dd_at
(
list
,
buf
,
count
));
return
(
str_list_a
ppend
(
list
,
buf
,
count
));
}
str_list_t
strListAdd
(
str_list_t
*
list
,
const
char
*
str
)
{
return
strListAddAt
(
list
,
str
,
strListCount
(
*
list
));
}
str_list_t
strListAddList
(
str_list_t
*
list
,
str_list_t
add_list
)
str_list_t
strListAddList
(
str_list_t
*
list
,
const
str_list_t
add_list
)
{
size_t
i
,
j
;
...
...
@@ -107,6 +124,28 @@ str_list_t strListAddList(str_list_t* list, str_list_t add_list)
return
(
*
list
);
}
str_list_t
strListInsert
(
str_list_t
*
list
,
const
char
*
str
,
size_t
index
)
{
char
*
buf
;
if
((
buf
=
(
char
*
)
malloc
(
strlen
(
str
)
+
1
))
==
NULL
)
return
(
NULL
);
strcpy
(
buf
,
str
);
return
(
str_list_insert
(
list
,
buf
,
index
));
}
str_list_t
strListInsertList
(
str_list_t
*
list
,
const
str_list_t
add_list
,
size_t
index
)
{
size_t
i
;
for
(
i
=
0
;
add_list
[
i
];
i
++
)
strListInsert
(
list
,
add_list
[
i
],
index
++
);
return
(
*
list
);
}
str_list_t
strListSplit
(
str_list_t
*
list
,
char
*
str
,
const
char
*
delimit
)
{
char
*
token
;
...
...
@@ -144,7 +183,7 @@ str_list_t strListMerge(str_list_t* list, str_list_t add_list)
j
=
strListCount
(
*
list
);
for
(
i
=
0
;
add_list
[
i
];
i
++
)
str_list_a
dd_at
(
list
,
add_list
[
i
],
j
++
);
str_list_a
ppend
(
list
,
add_list
[
i
],
j
++
);
return
(
*
list
);
}
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/str_list.h
+
8
−
2
View file @
2b2762b8
...
...
@@ -62,8 +62,14 @@ 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 */
str_list_t
strListAddList
(
str_list_t
*
list
,
str_list_t
append_list
);
/* Append a string list onto an 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 onto an another string list */
str_list_t
strListInsertList
(
str_list_t
*
list
,
const
str_list_t
append_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 */
...
...
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