forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

subsequenct sceIoRead calls crashing

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
sexdwarf



Joined: 14 Jul 2005
Posts: 34

PostPosted: Tue Jul 26, 2005 12:56 pm    Post subject: subsequenct sceIoRead calls crashing Reply with quote

i am having an issue reading with sceIoRead... any initial call works, however any subsequent calls crash the PSP, and i've concluded that it's not related to the file (switching the order works the same way) etc...

here is the code:
Code:

WaveInfo *wavLoad (char *filename)
{
    unsigned int filelen;
    unsigned long datalength;
    int data_offset;
    int id;
    int size;
    int fd;
    unsigned char   *wavfile;
    char            path_name[256];
    WaveInfo *wi;

    SceIoStat stat;
    sprintf(path_name,"%s%s", g_boot_path, filename);

    fd = sceIoOpen(path_name, PSP_O_RDONLY, 0777);

    if (fd<0)
    {
        printf("Failed loading: %s",path_name);
    }
    else
    {
// ---- Definatly gets here...
printf("1-GOT HERE\n");
        sceIoGetstat(path_name,&stat);
printf("2-GOT HERE\n");
        wi = malloc(stat.st_size + sizeof(WaveInfo));
printf("3-GOT HERE\n");

        wavfile = (char*)(wi + sizeof(WaveInfo));
printf("4-GOT HERE\n");
        filelen = sceIoRead(fd, wavfile, stat.st_size);
printf("5-GOT HERE\n");
        sceIoClose(fd);
printf("6-GOT HERE\n");

// dies before here


it always dies right after "4-GOT HERE" when being called a second time...anyone have any ideas?
_________________
...isn't it nice, sugar and spice...
...luring disco dollies to a life of vice...
Back to top
View user's profile Send private message
remleduff



Joined: 24 Jul 2005
Posts: 11

PostPosted: Tue Jul 26, 2005 3:20 pm    Post subject: Re: subsequenct sceIoRead calls crashing Reply with quote

sexdwarf wrote:

Code:

        wavfile = (char*)(wi + sizeof(WaveInfo));



sizeof(*wi) is presumably != sizeof(char) so you're overrunning the end of your memory.

Try:
wavfile = (char*)wi + sizeof(WaveInfo);

I would actually recommend you just allocate the two pointers in two separate mallocs.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group