From 5558f96e66bd583acbb6360888c9c15387870955 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 3 Jun 2014 05:54:42 +0200 Subject: allocate the states on the heap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/test/test.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/test/test.c b/src/test/test.c index 4d20aa8..886b361 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -179,13 +179,13 @@ static void error_test(void) int main(void) { + libgamma_site_state_t* site_state = malloc(sizeof(libgamma_site_state_t)); + libgamma_partition_state_t* part_state = malloc(sizeof(libgamma_partition_state_t)); + libgamma_crtc_state_t* crtc_state = malloc(sizeof(libgamma_crtc_state_t)); int method; char* site; char* tmp; char buf[256]; - libgamma_site_state_t site_state; - libgamma_partition_state_t part_state; - libgamma_crtc_state_t crtc_state; int r; list_methods_lists(); @@ -216,49 +216,49 @@ int main(void) memcpy(site, buf, strlen(buf) + 1); } - if ((r = libgamma_site_initialise(&site_state, method, site))) + if ((r = libgamma_site_initialise(site_state, method, site))) { free(site); return libgamma_perror("error", r), 1; } - if (site_state.partitions_available == 0) + if (site_state->partitions_available == 0) { - libgamma_site_destroy(&site_state); + libgamma_site_free(site_state); return printf("No partitions found\n"), 1; } - printf("Select partition [0, %lu]: ", site_state.partitions_available - 1); + printf("Select partition [0, %lu]: ", site_state->partitions_available - 1); fflush(stdout); fgets(buf, sizeof(buf) / sizeof(char), stdin); - if ((r = libgamma_partition_initialise(&part_state, &site_state, (size_t)atoll(buf)))) + if ((r = libgamma_partition_initialise(part_state, site_state, (size_t)atoll(buf)))) { - libgamma_site_destroy(&site_state); + libgamma_site_free(site_state); return libgamma_perror("error", r), 1; } - if (part_state.crtcs_available == 0) + if (part_state->crtcs_available == 0) { - libgamma_partition_destroy(&part_state); - libgamma_site_destroy(&site_state); + libgamma_partition_free(part_state); + libgamma_site_free(site_state); return printf("No CRTC:s found\n"), 1; } - printf("Select CRTC [0, %lu]: ", part_state.crtcs_available - 1); + printf("Select CRTC [0, %lu]: ", part_state->crtcs_available - 1); fflush(stdout); fgets(buf, sizeof(buf) / sizeof(char), stdin); - if ((r = libgamma_crtc_initialise(&crtc_state, &part_state, (size_t)atoll(buf)))) + if ((r = libgamma_crtc_initialise(crtc_state, part_state, (size_t)atoll(buf)))) { - libgamma_partition_destroy(&part_state); - libgamma_site_destroy(&site_state); + libgamma_partition_free(part_state); + libgamma_site_free(site_state); return libgamma_perror("error", r), 1; } - libgamma_crtc_destroy(&crtc_state); - libgamma_partition_destroy(&part_state); - libgamma_site_destroy(&site_state); + libgamma_crtc_free(crtc_state); + libgamma_partition_free(part_state); + libgamma_site_free(site_state); return 0; } -- cgit v1.2.3-70-g09d2