Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
3e44cbb7
Commit
3e44cbb7
authored
Jun 10, 2014
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
idtree: use ccan/tal instead of talloc
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
59208d61
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
10 deletions
+20
-10
ccan/idtree/_info
ccan/idtree/_info
+2
-2
ccan/idtree/idtree.c
ccan/idtree/idtree.c
+4
-4
ccan/idtree/test/run-wrap.c
ccan/idtree/test/run-wrap.c
+1
-1
ccan/idtree/test/run.c
ccan/idtree/test/run.c
+13
-3
No files found.
ccan/idtree/_info
View file @
3e44cbb7
...
...
@@ -14,7 +14,7 @@
*
* Example:
* #include <ccan/idtree/idtree.h>
* #include <ccan/tal
loc/talloc
.h>
* #include <ccan/tal
/tal
.h>
* #include <stdlib.h>
* #include <stdio.h>
*
...
...
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
return 1;
if (strcmp(argv[1], "depends") == 0) {
printf("ccan/tal
loc
\n");
printf("ccan/tal\n");
return 0;
}
...
...
ccan/idtree/idtree.c
View file @
3e44cbb7
...
...
@@ -25,7 +25,7 @@
*/
#include <ccan/idtree/idtree.h>
#include <ccan/tal
loc/talloc
.h>
#include <ccan/tal
/tal
.h>
#include <stdint.h>
#include <string.h>
...
...
@@ -87,7 +87,7 @@ static void free_layer(struct idtree *idp, struct idtree_layer *p)
static
int
idtree_pre_get
(
struct
idtree
*
idp
)
{
while
(
idp
->
id_free_cnt
<
IDTREE_FREE_MAX
)
{
struct
idtree_layer
*
pn
=
tal
loc_zero
(
idp
,
struct
idtree_layer
);
struct
idtree_layer
*
pn
=
tal
z
(
idp
,
struct
idtree_layer
);
if
(
pn
==
NULL
)
return
(
0
);
free_layer
(
idp
,
pn
);
...
...
@@ -313,14 +313,14 @@ bool idtree_remove(struct idtree *idp, int id)
}
while
(
idp
->
id_free_cnt
>=
IDTREE_FREE_MAX
)
{
p
=
alloc_layer
(
idp
);
tal
loc
_free
(
p
);
tal_free
(
p
);
}
return
true
;
}
struct
idtree
*
idtree_new
(
void
*
mem_ctx
)
{
return
tal
loc_zero
(
mem_ctx
,
struct
idtree
);
return
tal
z
(
mem_ctx
,
struct
idtree
);
}
int
idtree_add
(
struct
idtree
*
idp
,
const
void
*
ptr
,
int
limit
)
...
...
ccan/idtree/test/run-wrap.c
View file @
3e44cbb7
...
...
@@ -17,6 +17,6 @@ int main(int argc, char *argv[])
ok1
(
idtree_remove
(
idtree
,
INT_MAX
-
1
)
==
true
);
ok1
(
idtree_add_above
(
idtree
,
&
i
,
INT_MAX
-
1
,
INT_MAX
)
==
INT_MAX
-
1
);
ok1
(
idtree_add_above
(
idtree
,
&
i
,
INT_MAX
-
1
,
INT_MAX
)
==
-
1
);
tal
loc
_free
(
idtree
);
tal_free
(
idtree
);
exit
(
exit_status
());
}
ccan/idtree/test/run.c
View file @
3e44cbb7
...
...
@@ -4,6 +4,16 @@
#define ALLOC_MAX (2 * IDTREE_SIZE)
static
bool
check_tal_parent
(
const
tal_t
*
parent
,
const
tal_t
*
ctx
)
{
while
(
ctx
)
{
if
(
ctx
==
parent
)
return
true
;
ctx
=
tal_parent
(
ctx
);
}
return
false
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
unsigned
int
i
;
...
...
@@ -12,9 +22,9 @@ int main(int argc, char *argv[])
void
*
ctx
;
plan_tests
(
ALLOC_MAX
*
5
+
2
);
ctx
=
tal
loc_named_const
(
NULL
,
1
,
"test root"
);
ctx
=
tal
(
NULL
,
char
);
idtree
=
idtree_new
(
ctx
);
ok1
(
talloc_find_parent_byname
(
idtree
,
"test root"
)
==
ctx
);
ok1
(
check_tal_parent
(
ctx
,
idtree
)
);
for
(
i
=
0
;
i
<
ALLOC_MAX
;
i
++
)
{
int
id
=
idtree_add
(
idtree
,
&
allocated
[
i
],
ALLOC_MAX
-
1
);
...
...
@@ -42,6 +52,6 @@ int main(int argc, char *argv[])
for
(
i
=
0
;
i
<
ALLOC_MAX
;
i
++
)
{
ok1
(
idtree_lookup
(
idtree
,
i
)
==
&
allocated
[
i
]);
}
tal
loc
_free
(
ctx
);
tal_free
(
ctx
);
exit
(
exit_status
());
}
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