| 1 | module nspkg |
| 2 | |
| 3 | #flag -lalpm |
| 4 | #include <alpm.h> |
| 5 | |
| 6 | fn C.alpm_depmissing_free(&DepMissing) |
| 7 | fn C.alpm_fileconflict_free(&FileConflict) |
| 8 | |
| 9 | fn test_dependency_payloads_can_be_freed_by_either_implementation() { |
| 10 | for native in [false, true] { |
| 11 | mut missing := unsafe { &DepMissing(C.calloc(1, sizeof(DepMissing))) } |
| 12 | assert missing != unsafe { nil } |
| 13 | missing.target = unsafe { C.strdup(c'client') } |
| 14 | missing.depend = dep_from_string('library>=2') |
| 15 | missing.causingpkg = unsafe { C.strdup(c'library') } |
| 16 | if native { missing.free() } else { C.alpm_depmissing_free(missing) } |
| 17 | mut conflict := unsafe { &FileConflict(C.calloc(1, sizeof(FileConflict))) } |
| 18 | assert conflict != unsafe { nil } |
| 19 | conflict.target = unsafe { C.strdup(c'client') } |
| 20 | conflict.file = unsafe { C.strdup(c'usr/bin/client') } |
| 21 | conflict.ctarget = unsafe { C.strdup(c'other') } |
| 22 | if native { conflict.free() } else { C.alpm_fileconflict_free(conflict) } |
| 23 | } |
| 24 | unsafe { (&DepMissing(nil)).free() } |
| 25 | unsafe { (&FileConflict(nil)).free() } |
| 26 | } |
| 27 | |