From: <ny...@us...> - 2006-12-28 16:56:02
|
Revision: 219 http://svn.sourceforge.net/pmplib/?rev=219&view=rev Author: nyaochi Date: 2006-12-28 08:56:01 -0800 (Thu, 28 Dec 2006) Log Message: ----------- Do not cross a page boundary with AVL node and key. Modified Paths: -------------- trunk/pmplib/lib/pmp_iriverplus3/dat.c trunk/pmplib/lib/pmp_iriverplus3/idx.c Modified: trunk/pmplib/lib/pmp_iriverplus3/dat.c =================================================================== --- trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-28 16:22:43 UTC (rev 218) +++ trunk/pmplib/lib/pmp_iriverplus3/dat.c 2006-12-28 16:56:01 UTC (rev 219) @@ -369,7 +369,15 @@ dic->header.num_dat_pages += 1; } - /* Read Music page(s) */ + /* Clear filepath and filename */ + for (i = 0;i < dat->musics.num_entries;++i) { + static const ucs2char_t empty[] = {0}; + dat_entry_t* entry = &dat->musics.entries[i]; + ip3db_variant_set_str(&entry->fields[IP3DBF_MUSIC_FILEPATH], empty); + ip3db_variant_set_str(&entry->fields[IP3DBF_MUSIC_FILENAME], empty); + } + + /* Write Music page(s) */ i = 0; dat_list_write(&dat->musics, i, &ph, buffer, PAGESIZE * 1); dic->header.num_dat_pages += 1; @@ -378,7 +386,7 @@ buffer_size = PAGESIZE * page; buffer = (uint8_t*)realloc(buffer, sizeof(uint8_t) * buffer_size); i += ph.num_entries; - dat_list_write(&dat->objects, i, &ph, buffer, PAGESIZE * (page - 1)); + 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 16:22:43 UTC (rev 218) +++ trunk/pmplib/lib/pmp_iriverplus3/idx.c 2006-12-28 16:56:01 UTC (rev 219) @@ -142,9 +142,9 @@ avl->offset = offset; } -static uint32_t avlnode_new(avl_t* avl) +static uint32_t avlnode_new(avl_t* avl, size_t keysize) { - uint32_t offset = avl_allocate(avl, sizeof(avlnode_t)); + uint32_t offset = avl_allocate(avl, sizeof(avlnode_t) + keysize); avlnode_t* a = avlnode(avl, offset); a->left = 0; a->right = 0; @@ -332,25 +332,28 @@ int ret = 0; static avl_comp_t comp[] = {NULL, avl_comp_ucs2string, avl_comp_byte, avl_comp_word, avl_comp_dword}; uint32_t offset_prev = avl_current(avl); - uint32_t offset_this = avlnode_new(avl); - size_t size = 0; + uint32_t offset_this = 0; uint32_t offset_key = 0; switch (type) { case IP3DBVT_BYTE: - offset_key = avl_allocate(avl, sizeof(uint8_t)); + offset_this = avlnode_new(avl, sizeof(uint8_t)); + offset_key = offset_this + sizeof(avlnode_t); *((uint8_t*)avlnode(avl, offset_key)) = key->value.byte; break; case IP3DBVT_WORD: - offset_key = avl_allocate(avl, sizeof(uint16_t)); + offset_this = avlnode_new(avl, sizeof(uint16_t)); + offset_key = offset_this + sizeof(avlnode_t); *((uint16_t*)avlnode(avl, offset_key)) = key->value.word; break; case IP3DBVT_DWORD: - offset_key = avl_allocate(avl, sizeof(uint32_t)); + offset_this = avlnode_new(avl, sizeof(uint32_t)); + offset_key = offset_this + sizeof(avlnode_t); *((uint32_t*)avlnode(avl, offset_key)) = key->value.dword; break; case IP3DBVT_STRING: - offset_key = avl_allocate(avl, sizeof(ucs2char_t) * (ucs2len(key->value.str) + 1)); + offset_this = avlnode_new(avl, sizeof(ucs2char_t) * (ucs2len(key->value.str) + 1)); + offset_key = offset_this + sizeof(avlnode_t); ucs2cpy((ucs2char_t*)avlnode(avl, offset_key), key->value.str); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |