On 05/08/2007 03:53 PM, Pekka Enberg wrote:
+static int __mitsumi_read_toc(struct mitsumi_cdrom *mcd)
+{
+ int tracks = mcd->header.cdth_trk1 - mcd->header.cdth_trk0 + 1;
+ int retries;
+ int err = 0;
+
+ kfree(mcd->toc);
+
+ mcd->toc = kzalloc(tracks * sizeof *mcd->toc, GFP_KERNEL);
Perhaps we should use krealloc() + memset() here?
Earlier I had a patch lined up that checked the previous number of tracks
against the current number and only freed the TOC array when they were not
the same. The majority case is a data CD with one TOC entry meaning we just
reuse the entry. You then have to keep the previous number of tracks though
and it seemed a little pointless so I dropped it.
Another option is using a linked list for the TOC and reusing or allocating
nodes upon reading the actual entry from the Q channel and freeing the rest
when we got them all. Also seemed overly complex and the CDROMREADTOCENTRY
gets slower ;-)
I admit my DOS inspired dislike of realloc() is largely pointless these days
but, err... "E426: tag not found: krealloc". Would you perhaps like the
list? Or the if (tracks != mcd->tracks) thing?
Rene.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/