Skip to content

Instantly share code, notes, and snippets.

@madx
Created March 12, 2009 22:43
Show Gist options
  • Save madx/78332 to your computer and use it in GitHub Desktop.
Save madx/78332 to your computer and use it in GitHub Desktop.
#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->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);
}
void Line_addCity();
void Line_addTravel();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment