Modified structure.c

This commit is contained in:
Mario Danic 2006-10-12 17:31:58 +00:00
parent 6310bd0c74
commit ac6eed7aef

View File

@ -158,24 +158,25 @@ int burn_session_remove_track(struct burn_session *s, struct burn_track *t)
/* Find the position */ /* Find the position */
for (i = 0; i < s->tracks; i++) { for (i = 0; i < s->tracks; i++) {
if (t == s->track[i]) if (t == s->track[i]) {
pos = i; pos = i;
break;
}
} }
if (pos == -1) if (pos == -1)
return 0; return 0;
/* Is it the last track? */ /* Is it the last track? */
if (pos != s->tracks) { if (pos != s->tracks - 1) {
memmove(s->track[pos], s->track[pos + 1], memmove(&s->track[pos], &s->track[pos + 1],
sizeof(struct burn_track *) * (s->tracks - (pos + 1))); sizeof(struct burn_track *) * (s->tracks - (pos + 1)));
} }
s->tracks--; s->tracks--;
tmp = realloc(s->track, sizeof(struct burn_track *) * s->tracks); tmp = realloc(s->track, sizeof(struct burn_track *) * s->tracks);
if (!tmp) if (tmp)
return 0; s->track = tmp;
s->track = tmp;
return 1; return 1;
} }