Code: Select all
fat_entry_t *fat_handle_new_entry(fat_entry_t *parent, unsigned char *entry, fat_entry_t *prev)
{
if(fat_entry_exist(entry))
{
fat_entry_t *fat_entry = (fat_entry_t *)malloc(sizeof(fat_entry_t));
memcpy((void *)fat_entry, (void *)entry, FAT_DIR_ENTRY_LENGTH);
fat_entry->parent = parent;
if(prev != parent)
prev->next = fat_entry;
else
parent->first_child = fat_entry;
return fat_entry;
}
return 0;
}
I also tried as a replacment for the memcpy call:
Code: Select all
int i = 0;
unsigned char *buf = (unsigned char *)fat_entry;
for(;i<FAT_DIR_ENTRY_LENGTH;i++) buf[i] = entry[i];
Also, when displaying the buf outside the loop it doesn't work.
only when displaying these INSIDE the loop (either fat_entry and buf) it shows the correct data.
Also, I checked and they both point to the same place in any place of this function.
So what the hell happens when loop exists to my memory?
ANY IDEAS? Thanks in advance!