Created
March 12, 2009 22:56
-
-
Save madx/78343 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include "main.h" | |
Line * Line_new(int id, int city_c, int travel_c) { | |
int i; | |
Line * line = malloc(sizeof(Line)); | |
assert(line != NULL); | |
line->id = id; | |
line->city_c = city_c; | |
line->travel_c = travel_c; | |
line->cities = malloc(city_c * sizeof(int)); | |
assert(line->cities != NULL); | |
line->schedule = malloc(travel_c * sizeof(int*)); | |
assert(line->schedule != NULL); | |
for(i = 0; i < city_c; i++) { | |
line->schedule[i] = malloc(city_c * sizeof(int)); | |
assert(line->schedule[i] != NULL); | |
} | |
return line; | |
} | |
void Line_free(Line *line) { | |
int i; | |
free(line->cities); | |
for(i = 0; i < line->travel_c; i++) | |
free(line->schedule[i]); | |
free(line->schedule); | |
free(line); | |
} | |
void Line_addCity(); | |
void Line_addTravel(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment