forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ccan: upgrade to new ccan/tal and ccan/tal/str.
The visible changes are: 1. tal_len() is renamed to tal_bytelen() for clarity. 2. tal allocations *always* know their length. 3. tal/str routines always set the length to strlen() + 1. Signed-off-by: Rusty Russell <[email protected]>
- Loading branch information
1 parent
337075d
commit 5179025
Showing
18 changed files
with
285 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
CCAN imported from http://ccodearchive.net. | ||
|
||
CCAN version: init-2435-g92be2eff | ||
CCAN version: init-2440-g55d81423 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <ccan/structeq/structeq.h> | ||
|
||
struct mydata { | ||
int start, end; | ||
}; | ||
#ifdef FAIL | ||
#define PADDING -1 | ||
#else | ||
#define PADDING 0 | ||
#endif | ||
|
||
STRUCTEQ_DEF(mydata, PADDING, start, end); | ||
|
||
int main(void) | ||
{ | ||
struct mydata a = { 0, 100 }; | ||
|
||
return mydata_eq(&a, &a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <ccan/structeq/structeq.h> | ||
|
||
struct mydata { | ||
int start, end; | ||
}; | ||
#ifdef FAIL | ||
#define PADDING 1 | ||
#else | ||
#define PADDING 0 | ||
#endif | ||
|
||
STRUCTEQ_DEF(mydata, PADDING, start, end); | ||
|
||
int main(void) | ||
{ | ||
struct mydata a = { 0, 100 }; | ||
|
||
return mydata_eq(&a, &a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <ccan/structeq/structeq.h> | ||
|
||
struct mydata { | ||
int start, end; | ||
int pad; | ||
}; | ||
#ifdef FAIL | ||
#define PADDING 0 | ||
#else | ||
#define PADDING sizeof(int) | ||
#endif | ||
|
||
STRUCTEQ_DEF(mydata, PADDING, start, end); | ||
|
||
int main(void) | ||
{ | ||
struct mydata a = { 0, 100 }; | ||
|
||
return mydata_eq(&a, &a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <ccan/structeq/structeq.h> | ||
#include <ccan/tap/tap.h> | ||
|
||
/* In theory, this could be generated without padding, if alignof(int) were 0, | ||
* and test would fail. Call me when that happens. */ | ||
struct mydata { | ||
char start; | ||
int end; | ||
}; | ||
|
||
STRUCTEQ_DEF(mydata, sizeof(int) - sizeof(char), start, end); | ||
|
||
int main(void) | ||
{ | ||
struct mydata a, b; | ||
|
||
/* This is how many tests you plan to run */ | ||
plan_tests(3); | ||
|
||
a.start = 0; | ||
a.end = 100; | ||
ok1(mydata_eq(&a, &a)); | ||
|
||
b = a; | ||
ok1(mydata_eq(&a, &b)); | ||
|
||
b.end++; | ||
ok1(!mydata_eq(&a, &b)); | ||
|
||
/* This exits depending on whether all tests passed */ | ||
return exit_status(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.