diff options
-rw-r--r-- | apps/tagcache.c | 13 | ||||
-rw-r--r-- | firmware/export/config.h | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 850eaf9733..b485eb4647 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -783,7 +783,7 @@ static bool tempbuf_unique_insert(char *str, int id) if (!strcasecmp(str, index[i].str)) { tempbuf_left -= sizeof(struct tempbuf_id); - if (tempbuf_left < 0) + if (tempbuf_left - 4 < 0) return false; idp = index[i].id; @@ -791,6 +791,17 @@ static bool tempbuf_unique_insert(char *str, int id) idp = idp->next; idp->next = (struct tempbuf_id *)&tempbuf[tempbuf_pos]; +#ifdef ROCKBOX_STRICT_ALIGN + /* Make sure the entry is long aligned. */ + if ((long)idp->next & 0x03) + { + int fix = 4 - ((long)idp->next & 0x03); + tempbuf_left -= fix; + tempbuf_pos += fix; + idp->next = (struct tempbuf_id *)(( + (long)idp->next & ~0x03) + 0x04); + } +#endif idp = idp->next; idp->id = id; idp->next = NULL; diff --git a/firmware/export/config.h b/firmware/export/config.h index 5ac333d5e4..f99007304d 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -192,7 +192,7 @@ #endif /* Determine if accesses should be strictly long aligned. */ -#if (CONFIG_CPU == SH7034) || (CONFIG_CPU == CPU_ARM) +#if (CONFIG_CPU == SH7034) || defined(CPU_ARM) #define ROCKBOX_STRICT_ALIGN 1 #endif |