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
be4d15dc
Commit
be4d15dc
authored
19 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
DLL-xport some of the linked lsit stuff. More if it SHOULD be exported,
but this is all I need for a DLL-ified ciolib.
parent
26814418
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/link_list.c
+30
-30
30 additions, 30 deletions
src/xpdev/link_list.c
src/xpdev/link_list.h
+29
-29
29 additions, 29 deletions
src/xpdev/link_list.h
with
59 additions
and
59 deletions
src/xpdev/link_list.c
+
30
−
30
View file @
be4d15dc
...
...
@@ -51,7 +51,7 @@
#define MUTEX_UNLOCK(list)
#endif
link_list_t
*
listInit
(
link_list_t
*
list
,
long
flags
)
DLLEXPORT
link_list_t
*
DLLCALL
listInit
(
link_list_t
*
list
,
long
flags
)
{
if
(
flags
&
LINK_LIST_MALLOC
||
list
==
NULL
)
{
if
((
list
=
(
link_list_t
*
)
malloc
(
sizeof
(
link_list_t
)))
==
NULL
)
...
...
@@ -166,7 +166,7 @@ long listDettach(link_list_t* list)
return
(
refs
);
}
void
*
listSetPrivateData
(
link_list_t
*
list
,
void
*
p
)
DLLEXPORT
void
*
DLLCALL
listSetPrivateData
(
link_list_t
*
list
,
void
*
p
)
{
void
*
old
;
...
...
@@ -178,7 +178,7 @@ void* listSetPrivateData(link_list_t* list, void* p)
return
(
old
);
}
void
*
listGetPrivateData
(
link_list_t
*
list
)
DLLEXPORT
void
*
DLLCALL
listGetPrivateData
(
link_list_t
*
list
)
{
if
(
list
==
NULL
)
return
(
NULL
);
...
...
@@ -187,7 +187,7 @@ void* listGetPrivateData(link_list_t* list)
#if defined(LINK_LIST_THREADSAFE)
BOO
L
listSemPost
(
link_list_t
*
list
)
DLLEXPORT
BOOL
DLLCAL
L
listSemPost
(
link_list_t
*
list
)
{
if
(
list
==
NULL
||
!
(
list
->
flags
&
LINK_LIST_SEMAPHORE
))
return
(
FALSE
);
...
...
@@ -195,7 +195,7 @@ BOOL listSemPost(link_list_t* list)
return
(
sem_post
(
&
list
->
sem
)
==
0
);
}
BOO
L
listSemWait
(
link_list_t
*
list
)
DLLEXPORT
BOOL
DLLCAL
L
listSemWait
(
link_list_t
*
list
)
{
if
(
list
==
NULL
||
!
(
list
->
flags
&
LINK_LIST_SEMAPHORE
))
return
(
FALSE
);
...
...
@@ -203,7 +203,7 @@ BOOL listSemWait(link_list_t* list)
return
(
sem_wait
(
&
list
->
sem
)
==
0
);
}
BOO
L
listSemTryWait
(
link_list_t
*
list
)
DLLEXPORT
BOOL
DLLCAL
L
listSemTryWait
(
link_list_t
*
list
)
{
if
(
list
==
NULL
||
!
(
list
->
flags
&
LINK_LIST_SEMAPHORE
))
return
(
FALSE
);
...
...
@@ -211,7 +211,7 @@ BOOL listSemTryWait(link_list_t* list)
return
(
sem_trywait
(
&
list
->
sem
)
==
0
);
}
BOO
L
listSemTryWaitBlock
(
link_list_t
*
list
,
unsigned
long
timeout
)
DLLEXPORT
BOOL
DLLCAL
L
listSemTryWaitBlock
(
link_list_t
*
list
,
unsigned
long
timeout
)
{
if
(
list
==
NULL
||
!
(
list
->
flags
&
LINK_LIST_SEMAPHORE
))
return
(
FALSE
);
...
...
@@ -224,7 +224,7 @@ BOOL listSemTryWaitBlock(link_list_t* list, unsigned long timeout)
#if defined(__BORLANDC__)
#pragma argsused
#endif
void
listLock
(
const
link_list_t
*
list
)
DLLEXPORT
void
DLLCALL
listLock
(
const
link_list_t
*
list
)
{
MUTEX_LOCK
(
list
);
}
...
...
@@ -232,12 +232,12 @@ void listLock(const link_list_t* list)
#if defined(__BORLANDC__)
#pragma argsused
#endif
void
listUnlock
(
const
link_list_t
*
list
)
DLLEXPORT
void
DLLCALL
listUnlock
(
const
link_list_t
*
list
)
{
MUTEX_UNLOCK
(
list
);
}
long
listCountNodes
(
const
link_list_t
*
list
)
DLLEXPORT
long
DLLCALL
listCountNodes
(
const
link_list_t
*
list
)
{
long
count
=
0
;
list_node_t
*
node
;
...
...
@@ -258,7 +258,7 @@ long listCountNodes(const link_list_t* list)
return
(
count
);
}
list_node_t
*
listFindNode
(
const
link_list_t
*
list
,
const
void
*
data
,
size_t
length
)
DLLEXPORT
list_node_t
*
DLLCALL
listFindNode
(
const
link_list_t
*
list
,
const
void
*
data
,
size_t
length
)
{
list_node_t
*
node
;
...
...
@@ -327,7 +327,7 @@ str_list_t listSubStringList(const list_node_t* node, long max)
return
(
str_list
);
}
list_node_t
*
listFirstNode
(
const
link_list_t
*
list
)
DLLEXPORT
list_node_t
*
DLLCALL
listFirstNode
(
const
link_list_t
*
list
)
{
if
(
list
==
NULL
)
return
(
NULL
);
...
...
@@ -335,7 +335,7 @@ list_node_t* listFirstNode(const link_list_t* list)
return
(
list
->
first
);
}
list_node_t
*
listLastNode
(
const
link_list_t
*
list
)
DLLEXPORT
list_node_t
*
DLLCALL
listLastNode
(
const
link_list_t
*
list
)
{
list_node_t
*
node
;
list_node_t
*
last
=
NULL
;
...
...
@@ -356,7 +356,7 @@ list_node_t* listLastNode(const link_list_t* list)
return
(
last
);
}
long
listNodeIndex
(
const
link_list_t
*
list
,
list_node_t
*
find_node
)
DLLEXPORT
long
DLLCALL
listNodeIndex
(
const
link_list_t
*
list
,
list_node_t
*
find_node
)
{
long
i
=
0
;
list_node_t
*
node
;
...
...
@@ -378,7 +378,7 @@ long listNodeIndex(const link_list_t* list, list_node_t* find_node)
return
(
i
);
}
list_node_t
*
listNodeAt
(
const
link_list_t
*
list
,
long
index
)
DLLEXPORT
list_node_t
*
DLLCALL
listNodeAt
(
const
link_list_t
*
list
,
long
index
)
{
long
i
=
0
;
list_node_t
*
node
;
...
...
@@ -396,7 +396,7 @@ list_node_t* listNodeAt(const link_list_t* list, long index)
return
(
node
);
}
list_node_t
*
listNextNode
(
const
list_node_t
*
node
)
DLLEXPORT
list_node_t
*
DLLCALL
listNextNode
(
const
list_node_t
*
node
)
{
if
(
node
==
NULL
)
return
(
NULL
);
...
...
@@ -404,7 +404,7 @@ list_node_t* listNextNode(const list_node_t* node)
return
(
node
->
next
);
}
list_node_t
*
listPrevNode
(
const
list_node_t
*
node
)
DLLEXPORT
list_node_t
*
DLLCALL
listPrevNode
(
const
list_node_t
*
node
)
{
if
(
node
==
NULL
)
return
(
NULL
);
...
...
@@ -412,7 +412,7 @@ list_node_t* listPrevNode(const list_node_t* node)
return
(
node
->
prev
);
}
void
*
listNodeData
(
const
list_node_t
*
node
)
DLLEXPORT
void
*
DLLCALL
listNodeData
(
const
list_node_t
*
node
)
{
if
(
node
==
NULL
)
return
(
NULL
);
...
...
@@ -420,12 +420,12 @@ void* listNodeData(const list_node_t* node)
return
(
node
->
data
);
}
BOO
L
listNodeIsLocked
(
const
list_node_t
*
node
)
DLLEXPORT
BOOL
DLLCAL
L
listNodeIsLocked
(
const
list_node_t
*
node
)
{
return
(
node
!=
NULL
&&
node
->
flags
&
LINK_LIST_NODE_LOCKED
);
}
BOO
L
listLockNode
(
list_node_t
*
node
)
DLLEXPORT
BOOL
DLLCAL
L
listLockNode
(
list_node_t
*
node
)
{
if
(
node
==
NULL
||
node
->
flags
&
LINK_LIST_NODE_LOCKED
)
return
(
FALSE
);
...
...
@@ -435,7 +435,7 @@ BOOL listLockNode(list_node_t* node)
return
(
TRUE
);
}
BOO
L
listUnlockNode
(
list_node_t
*
node
)
DLLEXPORT
BOOL
DLLCAL
L
listUnlockNode
(
list_node_t
*
node
)
{
if
(
!
listNodeIsLocked
(
node
))
return
(
FALSE
);
...
...
@@ -482,7 +482,7 @@ static list_node_t* list_add_node(link_list_t* list, list_node_t* node, list_nod
return
(
node
);
}
list_node_t
*
listAddNode
(
link_list_t
*
list
,
void
*
data
,
list_node_t
*
after
)
DLLEXPORT
list_node_t
*
DLLCALL
listAddNode
(
link_list_t
*
list
,
void
*
data
,
list_node_t
*
after
)
{
list_node_t
*
node
;
...
...
@@ -498,7 +498,7 @@ list_node_t* listAddNode(link_list_t* list, void* data, list_node_t* after)
return
(
list_add_node
(
list
,
node
,
after
));
}
long
listAddNodes
(
link_list_t
*
list
,
void
**
data
,
list_node_t
*
after
)
DLLEXPORT
long
DLLCALL
listAddNodes
(
link_list_t
*
list
,
void
**
data
,
list_node_t
*
after
)
{
long
i
;
list_node_t
*
node
=
NULL
;
...
...
@@ -527,7 +527,7 @@ list_node_t* listAddNodeData(link_list_t* list, const void* data, size_t length,
return
(
NULL
);
}
node
->
flags
|=
LINK_LIST_MALLOC
;
return
(
node
);
}
...
...
@@ -551,7 +551,7 @@ list_node_t* listAddNodeString(link_list_t* list, const char* str, list_node_t*
return
(
node
);
}
long
listAddStringList
(
link_list_t
*
list
,
str_list_t
str_list
,
list_node_t
*
after
)
DLLEXPORT
long
DLLCALL
listAddStringList
(
link_list_t
*
list
,
str_list_t
str_list
,
list_node_t
*
after
)
{
long
i
;
list_node_t
*
node
=
NULL
;
...
...
@@ -566,7 +566,7 @@ long listAddStringList(link_list_t* list, str_list_t str_list, list_node_t* afte
return
(
i
);
}
long
listAddNodeList
(
link_list_t
*
list
,
const
link_list_t
*
src
,
list_node_t
*
after
)
DLLEXPORT
long
DLLCALL
listAddNodeList
(
link_list_t
*
list
,
const
link_list_t
*
src
,
list_node_t
*
after
)
{
long
count
=
0
;
list_node_t
*
node
=
NULL
;
...
...
@@ -584,7 +584,7 @@ long listAddNodeList(link_list_t* list, const link_list_t* src, list_node_t* aft
return
(
count
);
}
long
listMerge
(
link_list_t
*
list
,
const
link_list_t
*
src
,
list_node_t
*
after
)
DLLEXPORT
long
DLLCALL
listMerge
(
link_list_t
*
list
,
const
link_list_t
*
src
,
list_node_t
*
after
)
{
long
count
=
0
;
list_node_t
*
node
=
NULL
;
...
...
@@ -600,7 +600,7 @@ long listMerge(link_list_t* list, const link_list_t* src, list_node_t* after)
return
(
count
);
}
link_list_t
*
listExtract
(
link_list_t
*
dest_list
,
const
list_node_t
*
node
,
long
max
)
DLLEXPORT
link_list_t
*
DLLCALL
listExtract
(
link_list_t
*
dest_list
,
const
list_node_t
*
node
,
long
max
)
{
long
count
;
link_list_t
*
list
;
...
...
@@ -619,7 +619,7 @@ link_list_t* listExtract(link_list_t* dest_list, const list_node_t* node, long m
return
(
list
);
}
void
*
listRemoveNode
(
link_list_t
*
list
,
list_node_t
*
node
,
BOOL
free_data
)
DLLEXPORT
void
*
DLLCALL
listRemoveNode
(
link_list_t
*
list
,
list_node_t
*
node
,
BOOL
free_data
)
{
void
*
data
;
...
...
@@ -681,7 +681,7 @@ long listRemoveNodes(link_list_t* list, list_node_t* node, long max, BOOL free_d
return
(
count
);
}
BOO
L
listSwapNodes
(
list_node_t
*
node1
,
list_node_t
*
node2
)
DLLEXPORT
BOOL
DLLCAL
L
listSwapNodes
(
list_node_t
*
node1
,
list_node_t
*
node2
)
{
list_node_t
tmp
;
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/link_list.h
+
29
−
29
View file @
be4d15dc
...
...
@@ -83,7 +83,7 @@ typedef struct link_list {
}
link_list_t
;
/* Initialization, Allocation, and Freeing of Lists and Nodes */
link_list_t
*
listInit
(
link_list_t
*
/* NULL to auto-allocate */
,
long
flags
);
DLLEXPORT
link_list_t
*
DLLCALL
listInit
(
link_list_t
*
/* NULL to auto-allocate */
,
long
flags
);
BOOL
listFree
(
link_list_t
*
);
long
listFreeNodes
(
link_list_t
*
);
BOOL
listFreeNodeData
(
list_node_t
*
node
);
...
...
@@ -93,23 +93,23 @@ long listAttach(link_list_t*);
long
listDetach
(
link_list_t
*
);
#if defined(LINK_LIST_THREADSAFE)
BOOL
listSemPost
(
link_list_t
*
);
BOOL
listSemWait
(
link_list_t
*
);
BOOL
listSemTryWait
(
link_list_t
*
);
BOOL
listSemTryWaitBlock
(
link_list_t
*
,
unsigned
long
timeout
);
DLLEXPORT
BOOL
DLLCALL
listSemPost
(
link_list_t
*
);
DLLEXPORT
BOOL
DLLCALL
listSemWait
(
link_list_t
*
);
DLLEXPORT
BOOL
DLLCALL
listSemTryWait
(
link_list_t
*
);
DLLEXPORT
BOOL
DLLCALL
listSemTryWaitBlock
(
link_list_t
*
,
unsigned
long
timeout
);
#endif
/* Lock/unlock mutex-protected linked lists (no-op for unprotected lists) */
void
listLock
(
const
link_list_t
*
);
void
listUnlock
(
const
link_list_t
*
);
DLLEXPORT
void
DLLCALL
listLock
(
const
link_list_t
*
);
DLLEXPORT
void
DLLCALL
listUnlock
(
const
link_list_t
*
);
/* Return count or index of nodes, or -1 on error */
long
listCountNodes
(
const
link_list_t
*
);
long
listNodeIndex
(
const
link_list_t
*
,
list_node_t
*
);
DLLEXPORT
long
DLLCALL
listCountNodes
(
const
link_list_t
*
);
DLLEXPORT
long
DLLCALL
listNodeIndex
(
const
link_list_t
*
,
list_node_t
*
);
/* Get/Set list private data */
void
*
listSetPrivateData
(
link_list_t
*
,
void
*
);
void
*
listGetPrivateData
(
link_list_t
*
);
DLLEXPORT
void
*
DLLCALL
listSetPrivateData
(
link_list_t
*
,
void
*
);
DLLEXPORT
void
*
DLLCALL
listGetPrivateData
(
link_list_t
*
);
/* Return an allocated string list (which must be freed), array of all strings in linked list */
str_list_t
listStringList
(
const
link_list_t
*
);
...
...
@@ -119,29 +119,29 @@ str_list_t listSubStringList(const list_node_t*, long max);
/* Extract subset (up to max number of nodes) in linked list (src_node) and place into dest_list */
/* dest_list == NULL, then allocate a return a new linked list */
link_list_t
*
listExtract
(
link_list_t
*
dest_list
,
const
list_node_t
*
src_node
,
long
max
);
DLLEXPORT
link_list_t
*
DLLCALL
listExtract
(
link_list_t
*
dest_list
,
const
list_node_t
*
src_node
,
long
max
);
/* Simple search functions returning found node or NULL on error */
list_node_t
*
listNodeAt
(
const
link_list_t
*
,
long
index
);
list_node_t
*
listFindNode
(
const
link_list_t
*
,
const
void
*
data
,
size_t
length
);
DLLEXPORT
list_node_t
*
DLLCALL
listNodeAt
(
const
link_list_t
*
,
long
index
);
DLLEXPORT
list_node_t
*
DLLCALL
listFindNode
(
const
link_list_t
*
,
const
void
*
data
,
size_t
length
);
/* Convenience functions */
list_node_t
*
listFirstNode
(
const
link_list_t
*
);
list_node_t
*
listLastNode
(
const
link_list_t
*
);
list_node_t
*
listNextNode
(
const
list_node_t
*
);
list_node_t
*
listPrevNode
(
const
list_node_t
*
);
void
*
listNodeData
(
const
list_node_t
*
);
DLLEXPORT
list_node_t
*
DLLCALL
listFirstNode
(
const
link_list_t
*
);
DLLEXPORT
list_node_t
*
DLLCALL
listLastNode
(
const
link_list_t
*
);
DLLEXPORT
list_node_t
*
DLLCALL
listNextNode
(
const
list_node_t
*
);
DLLEXPORT
list_node_t
*
DLLCALL
listPrevNode
(
const
list_node_t
*
);
DLLEXPORT
void
*
DLLCALL
listNodeData
(
const
list_node_t
*
);
/* Primitive node locking */
BOOL
listLockNode
(
list_node_t
*
);
BOOL
listUnlockNode
(
list_node_t
*
);
BOOL
listNodeIsLocked
(
const
list_node_t
*
);
DLLEXPORT
BOOL
DLLCALL
listLockNode
(
list_node_t
*
);
DLLEXPORT
BOOL
DLLCALL
listUnlockNode
(
list_node_t
*
);
DLLEXPORT
BOOL
DLLCALL
listNodeIsLocked
(
const
list_node_t
*
);
/* Add node to list, returns pointer to new node or NULL on error */
list_node_t
*
listAddNode
(
link_list_t
*
,
void
*
data
,
list_node_t
*
after
/* NULL=insert */
);
DLLEXPORT
list_node_t
*
DLLCALL
listAddNode
(
link_list_t
*
,
void
*
data
,
list_node_t
*
after
/* NULL=insert */
);
/* Add array of node data to list, returns number of nodes added (or negative on error) */
long
listAddNodes
(
link_list_t
*
,
void
**
data
,
list_node_t
*
after
/* NULL=insert */
);
DLLEXPORT
long
DLLCALL
listAddNodes
(
link_list_t
*
,
void
**
data
,
list_node_t
*
after
/* NULL=insert */
);
/* Add node to list, allocating and copying the data for the node */
list_node_t
*
listAddNodeData
(
link_list_t
*
,
const
void
*
data
,
size_t
length
,
list_node_t
*
after
);
...
...
@@ -150,17 +150,17 @@ list_node_t* listAddNodeData(link_list_t*, const void* data, size_t length, list
list_node_t
*
listAddNodeString
(
link_list_t
*
,
const
char
*
str
,
list_node_t
*
after
);
/* Add a list of strings to the linked list, allocating and copying each */
long
listAddStringList
(
link_list_t
*
,
str_list_t
,
list_node_t
*
after
);
DLLEXPORT
long
DLLCALL
listAddStringList
(
link_list_t
*
,
str_list_t
,
list_node_t
*
after
);
/* Add a list of nodes from a source linked list */
long
listAddNodeList
(
link_list_t
*
,
const
link_list_t
*
src
,
list_node_t
*
after
);
DLLEXPORT
long
DLLCALL
listAddNodeList
(
link_list_t
*
,
const
link_list_t
*
src
,
list_node_t
*
after
);
/* Merge a source linked list into the destination linked list */
/* after merging, the nodes in the source linked list should not be modified or freed */
long
listMerge
(
link_list_t
*
dest
,
const
link_list_t
*
src
,
list_node_t
*
after
);
DLLEXPORT
long
DLLCALL
listMerge
(
link_list_t
*
dest
,
const
link_list_t
*
src
,
list_node_t
*
after
);
/* Swap the data pointers and flags for 2 nodes (possibly in separate lists) */
BOOL
listSwapNodes
(
list_node_t
*
node1
,
list_node_t
*
node2
);
DLLEXPORT
BOOL
DLLCALL
listSwapNodes
(
list_node_t
*
node1
,
list_node_t
*
node2
);
/* Convenience macros for pushing, popping, and inserting nodes */
#define listPushNode(list, data) listAddNode(list, data, listLastNode(list))
...
...
@@ -175,7 +175,7 @@ BOOL listSwapNodes(list_node_t* node1, list_node_t* node2);
#define listShiftNode(list) listRemoveNode(list, FIRST_NODE, FALSE)
/* Remove node from list, returning the node's data (if not free'd) */
void
*
listRemoveNode
(
link_list_t
*
,
list_node_t
*
/* NULL=first */
,
BOOL
free_data
);
DLLEXPORT
void
*
DLLCALL
listRemoveNode
(
link_list_t
*
,
list_node_t
*
/* NULL=first */
,
BOOL
free_data
);
/* Remove multiple nodes from list, returning the number of nodes removed */
long
listRemoveNodes
(
link_list_t
*
,
list_node_t
*
/* NULL=first */
,
long
count
,
BOOL
free_data
);
...
...
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