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 

memset problem

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



Joined: 30 Mar 2008
Posts: 261

PostPosted: Wed May 20, 2009 1:12 am    Post subject: memset problem Reply with quote

I have a problem when i use memset in my constructor.

This is my source:
Code:
Image::Image(int Width,int Height) {
    memset(data,0,Width*Height*sizeof(u32));
    width=Width;
    height=Height;
    x=0;
    y=0;
    origx=0;
    origy=0;
    swizzled=0;   
}

data is:
Code:
u32 * data


When i use gdb it said that it crashes by the memset function.

What do i wrong?
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
ps3fanboy



Joined: 06 Jul 2008
Posts: 66

PostPosted: Wed May 20, 2009 2:24 am    Post subject: Reply with quote

data is a pointer and it looks like there is no memory allocated.
so, before you can use memset you have to malloc some memory to the pointer.
_________________
http://playstation3-homebrew-multimedia.blogspot.com/
Back to top
View user's profile Send private message
jbit
Site Admin


Joined: 28 May 2005
Posts: 293
Location: København, Danmark

PostPosted: Wed May 20, 2009 10:35 am    Post subject: Reply with quote

Learn C/C++, then code on PSP... These forums aren't for basic code questions, there are PLENNNTTTY of forums for that.
Back to top
View user's profile Send private message Visit poster's website
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Thu May 21, 2009 2:05 am    Post subject: Reply with quote

jbit wrote:
Learn C/C++, then code on PSP... These forums aren't for basic code questions, there are PLENNNTTTY of forums for that.


I know how to code c++ and this isn't my first thing op psp.

This is just the kind of mistake i often do. (use memset instead of malloc)
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
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