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
6e1450e6
Commit
6e1450e6
authored
May 31, 2009
by
Rusty Russell
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
1f67bcee
88a111e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
+19
-17
ccan/array/_info
ccan/array/_info
+1
-1
ccan/array/array.h
ccan/array/array.h
+4
-2
ccan/array/test/run.c
ccan/array/test/run.c
+14
-14
No files found.
ccan/array/_info
View file @
6e1450e6
...
...
@@ -42,7 +42,7 @@
* }
*
* Author: Joey Adams
* Version: 0.1
* Version: 0.1
.1
* Licence: BSD
*/
int main(int argc, char *argv[])
...
...
ccan/array/array.h
View file @
6e1450e6
...
...
@@ -38,7 +38,9 @@
#include <ccan/talloc/talloc.h>
#endif
#ifndef HAVE_ATTRIBUTE_MAY_ALIAS
#define HAVE_ATTRIBUTE_MAY_ALIAS 1
#endif
//Use the array_alias macro to indicate that a pointer has changed but strict aliasing rules are too stupid to know it
#if HAVE_ATTRIBUTE_MAY_ALIAS==1
...
...
@@ -88,7 +90,7 @@
#define array_append_items(array, items, count) do {size_t __count = (count); array_resize(array, (array).size+__count); memcpy((array).item+(array).size-__count, items, __count*sizeof(*(array).item));} while(0)
#define array_prepend(array, ...) do {array_resize(array, (array).size+1); memmove((array).item+1, (array).item, ((array).size-1)*sizeof(*(array).item)); *(array).item = (__VA_ARGS__);} while(0)
#define array_push(array, ...) array_append(array, __VA_ARGS__)
#define array_pop
(array) ((array).size ? array_pop_nocheck
(array) : NULL)
#define array_pop
_check(array) ((array).size ? array_pop
(array) : NULL)
#define array_growalloc(array, newAlloc) do {size_t __newAlloc=(newAlloc); if (__newAlloc > (array).alloc) array_realloc(array, (__newAlloc+63)&~63); } while(0)
#if HAVE_STATEMENT_EXPR==1
...
...
@@ -97,7 +99,7 @@
//We do just fine by ourselves
#define array_pop
_nocheck
(array) ((array).item[--(array).size])
#define array_pop(array) ((array).item[--(array).size])
#if HAVE_TYPEOF==1
...
...
ccan/array/test/run.c
View file @
6e1450e6
...
...
@@ -58,7 +58,7 @@ int main(void) {
}
reset
(
arr
);
testing
(
array_prepend
,
array_pop
_nocheck
);
testing
(
array_prepend
,
array_pop
);
{
for
(
i
=
countof
(
lotsOfNumbers
);
i
;)
array_prepend
(
arr
,
lotsOfNumbers
[
--
i
]);
...
...
@@ -67,7 +67,7 @@ int main(void) {
ok1
(
!
memcmp
(
arr
.
item
,
lotsOfNumbers
,
sizeof
(
lotsOfNumbers
)));
for
(
i
=
countof
(
lotsOfNumbers
);
i
;)
{
if
(
array_pop
_nocheck
(
arr
)
!=
(
long
)
lotsOfNumbers
[
--
i
])
{
if
(
array_pop
(
arr
)
!=
(
long
)
lotsOfNumbers
[
--
i
])
{
i
++
;
break
;
}
...
...
@@ -251,7 +251,7 @@ int main(void) {
}
reset
(
str
);
testing
(
array_appends
,
array_prepends
,
array_pop
);
testing
(
array_appends
,
array_prepends
,
array_pop
_check
);
{
#ifndef ARRAY_USE_TALLOC
array
(
const
char
*
)
array
=
array_new
();
...
...
@@ -276,19 +276,19 @@ int main(void) {
array
.
item
[
7
]
==
n
[
7
]
&&
array
.
item
[
8
]
==
n
[
8
]);
ok1
(
array_pop
(
array
)
==
n
[
8
]
&&
array_pop
(
array
)
==
n
[
7
]
&&
array_pop
(
array
)
==
n
[
6
]
&&
array_pop
(
array
)
==
n
[
5
]
&&
array_pop
(
array
)
==
n
[
4
]
&&
array_pop
(
array
)
==
n
[
3
]
&&
array_pop
(
array
)
==
n
[
2
]
&&
array_pop
(
array
)
==
n
[
1
]
&&
array_pop
(
array
)
==
n
[
0
]);
ok1
(
array_pop
_check
(
array
)
==
n
[
8
]
&&
array_pop
_check
(
array
)
==
n
[
7
]
&&
array_pop
_check
(
array
)
==
n
[
6
]
&&
array_pop
_check
(
array
)
==
n
[
5
]
&&
array_pop
_check
(
array
)
==
n
[
4
]
&&
array_pop
_check
(
array
)
==
n
[
3
]
&&
array_pop
_check
(
array
)
==
n
[
2
]
&&
array_pop
_check
(
array
)
==
n
[
1
]
&&
array_pop
_check
(
array
)
==
n
[
0
]);
ok1
(
array
.
size
==
0
);
ok1
(
array_pop
(
array
)
==
NULL
&&
array_pop
(
array
)
==
NULL
&&
array_pop
(
array
)
==
NULL
);
ok1
(
array_pop
_check
(
array
)
==
NULL
&&
array_pop_check
(
array
)
==
NULL
&&
array_pop_check
(
array
)
==
NULL
);
array_free
(
array
);
}
...
...
@@ -296,7 +296,7 @@ int main(void) {
trace
(
"Freeing amalgams (internal)"
);
freeAmalgams
();
return
0
;
return
exit_status
()
;
}
static
void
generateAmalgams
(
void
)
{
...
...
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