From: <ny...@us...> - 2006-12-29 01:59:31
|
Revision: 222 http://svn.sourceforge.net/pmplib/?rev=222&view=rev Author: nyaochi Date: 2006-12-28 17:59:32 -0800 (Thu, 28 Dec 2006) Log Message: ----------- Some bug fixes: - Avoid id3_file_fdopen() since it will close files multiple times with fclose() and id_file_close(id3file) - Initialize new memory blocks allocated for db.dat - Avoid crossing a page boundary in db.idx - Change the algorithm to sort strings in db.idx to case-insensitive. Modified Paths: -------------- trunk/pmplib/lib/gmi/gmi_mp3.c trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/idx.c Modified: trunk/pmplib/lib/gmi/gmi_mp3.c =================================================================== --- trunk/pmplib/lib/gmi/gmi_mp3.c 2006-12-28 17:40:06 UTC (rev 221) +++ trunk/pmplib/lib/gmi/gmi_mp3.c 2006-12-29 01:59:32 UTC (rev 222) @@ -334,16 +334,11 @@ ucs2char_t* ucs2 = NULL; struct id3_file *id3file = NULL; struct id3_tag *id3tag = NULL; + char* pathname = ucs2dupmbs(filename); - /* Open the file with UNICODE filename. This is for better compatibility. */ - fp = ucs2fopen(filename, "rb"); - if (!fp) { - return -1; - } - /* Open with libid3tag */ - /*id3file = id3_file_open(pathname, ID3_FILE_MODE_READONLY);*/ - id3file = id3_file_fdopen(fileno(fp), ID3_FILE_MODE_READONLY); + id3file = id3_file_open(pathname, ID3_FILE_MODE_READONLY); + ucs2free(pathname); if (!id3file) { fclose(fp); return -1; Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-28 17:40:06 UTC (rev 221) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-29 01:59:32 UTC (rev 222) @@ -364,6 +364,7 @@ uint32_t page = ph.next_page++; buffer_size = PAGESIZE * page; buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); + memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); i += ph.num_entries; dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1)); dic->header.num_dat_pages += 1; @@ -386,6 +387,7 @@ uint32_t page = ph.next_page++; buffer_size = PAGESIZE * page; buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); + memset(buffer + PAGESIZE * (page - 1), 0, PAGESIZE); i += ph.num_entries; dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * (page - 1)); dic->header.num_dat_pages += 1; Modified: trunk/pmplib/lib/pmp_iriverplus3/idx.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/idx.c 2006-12-28 17:40:06 UTC (rev 221) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2006-12-29 01:59:32 UTC (rev 222) @@ -117,6 +117,10 @@ memset(avl->buffer + avl->size, 0, PAGESIZE); avl->offset = avl->size + sizeof(header_t); avl->size = newsize; + } else if (((avl->offset + size) / PAGESIZE) != (avl->offset / PAGESIZE)) { + /* Avoid crossing a page boundary. */ + uint32_t page = (avl->offset + size) / PAGESIZE; + avl->offset = PAGESIZE * page + sizeof(header_t); } /* Allocate a memory block. */ @@ -320,11 +324,18 @@ { ucs2char_t* x = (ucs2char_t*)(avl->buffer + _x); ucs2char_t* y = (ucs2char_t*)(avl->buffer + _y); - while (*x && *y && *x == *y) { + ucs2char_t a, b; + + do { + a = ucs2upper(*x); + b = ucs2upper(*y); + if (!*x || !*y) { + break; + } x++; y++; - } - return COMP(*x, *y); + } while (a == b); + return COMP(a, b); } static int avl_insert_key(avl_t* avl, const ip3db_variant_t* key, int type, uint32_t* offset, uint32_t* root) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |