Navigation
Views: changelog,
tags,
manifest,
raw
zip, gz, bz2,
Avoid memmove and memchr, just loop manually.
| changeset 125: |
212d63b751ed |
| parent 124: | 622a1f661fc4 |
| child 126: | be8d532a17b3 |
| author: |
Thomas Klausner <tk@giga.or.at> |
| date: |
Mon Aug 13 14:43:49 2007 +0200 (3 years ago) |
| files: |
id3.c |
| description: |
Avoid memmove and memchr, just loop manually. |
--- a/id3.c Mon Aug 13 14:14:54 2007 +0200
+++ b/id3.c Mon Aug 13 14:43:49 2007 +0200
@@ -350,23 +350,27 @@ unsynchronise(const unsigned char *data,
unsynchronise(const unsigned char *data, int len, int *taglenp)
{
unsigned char *tagdata, *p;
+ int i;
if ((tagdata=(unsigned char *)malloc(len)) == NULL)
return NULL;
- memcpy(tagdata, data, len);
p = tagdata;
- while ((p=memchr(p, 0xFF, tagdata+len-p)) != NULL) {
- p++;
- if (*p != 0x00)
+ for (i=0; i<len; i++) {
+ if ((data[i] != 0xFF) || (data[i+1] != 0x00)) {
+ *p = data[i];
+ p++;
continue;
-
- /* unsynchronisation tag, remove 0x00 */
- memmove(p, p+1, tagdata+len-p);
- len--;
- }
-
- *taglenp = len;
+ }
+ if ((data[i+2] != 0x00) && ((data[i+2]&0xe0) != 0xe0))
+ printf(" invalid unsynchronisation of 0x%.2x%.2x%.2x\n",
+ data[i], data[i+1], data[i+2]);
+ *p++ = data[i];
+ /* skip 0x00 */
+ i++;
+ }
+
+ *taglenp = p - tagdata;
return tagdata;
}
Powered by Mercurial.
|