Browse Source
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 <rusty@rustcorp.com.au>ppa-0.6.1
Rusty Russell
7 years ago
committed by
Christian Decker
18 changed files with 285 additions and 202 deletions
@ -1,3 +1,3 @@ |
|||
CCAN imported from http://ccodearchive.net. |
|||
|
|||
CCAN version: init-2435-g92be2eff |
|||
CCAN version: init-2440-g55d81423 |
|||
|
@ -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); |
|||
} |
@ -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); |
|||
} |
@ -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); |
|||
} |
@ -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(); |
|||
} |
Loading…
Reference in new issue