ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since cf966b5 was
3fb7f5e,
checked in by Aaron Moss <a3moss@…>, 7 years ago
|
Update benchmarks, cleanup edits to the evaluation section
|
-
Property mode set to
100644
|
File size:
803 bytes
|
Rev | Line | |
---|
[87c5f40] | 1 | #include <stdlib.h> |
---|
| 2 | #include "c-pair.h" |
---|
| 3 | |
---|
| 4 | struct pair* new_pair(void* first, void* second) { |
---|
[3fb7f5e] | 5 | struct pair* p = malloc(sizeof(struct pair)); /***/ |
---|
| 6 | *p = (struct pair){ first, second }; /***/ |
---|
[87c5f40] | 7 | return p; |
---|
| 8 | } |
---|
| 9 | |
---|
| 10 | struct pair* copy_pair(const struct pair* src, |
---|
| 11 | void* (*copy_first)(const void*), void* (*copy_second)(const void*)) { |
---|
| 12 | return new_pair( copy_first(src->first), copy_second(src->second) ); |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | void free_pair(struct pair* p, void (*free_first)(void*), void (*free_second)(void*)) { |
---|
| 16 | free_first(p->first); |
---|
| 17 | free_second(p->second); |
---|
| 18 | free(p); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | int cmp_pair(const struct pair* a, const struct pair* b, |
---|
| 22 | int (*cmp_first)(const void*, const void*), int (*cmp_second)(const void*, const void*)) { |
---|
| 23 | int c = cmp_first(a->first, b->first); |
---|
| 24 | if ( c == 0 ) c = cmp_second(a->second, b->second); |
---|
| 25 | return c; |
---|
| 26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.