Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Knight52   Members   -  Reputation: 171

Like
0Likes
Like

Posted 27 July 2012 - 08:35 AM

This is a part of the code of character's inventory system. This part will swap two inventory slots (itemslot[i][j] and highlight). They will swap array of item pointer, number of item in that slot(stack), default slot background and current slot background. It's fine when they swap for the first time, but when trying to swap back, that error occured, right after break; command.

I've googled a bit and found out this error has something to do with segment fault or memory leaks, but I have no idea which part of the code that cause this. Can anyone point out?

None of these function leads to delete or delete[], btw;

    for(int i = 0; i< 5; i++) for(int j = 0; j< 5; j++)
    {
	 if(itemslot[i][j]->button->Intersects(base))
	 {
	  ItemSlot slot = *itemslot[i][j];
	  itemslot[i][j]->stack = highlight->stack;
	  itemslot[i][j]->item = highlight->item;	 
	  stringstream s, s2;
	  s << itemslot[i][j]->stack;
	  itemslot[i][j]->button->SetText(s.str());
	  itemslot[i][j]->buttondefaultimage = highlight->buttondefaultimage;
	  highlight->stack = slot.stack;
	  highlight->item = slot.item;	 
	  s2 << slot.stack;	 
	  highlight->button->SetText((slot.stack > 0)? s2.str() : "");
	  highlight->buttondefaultimage = slot.buttondefaultimage;
	  for(int k = 0; k< 3; k++)
	  {
	   Image *img = itemslot[i][j]->button->GetImage(k);
	   itemslot[i][j]->button->SetImage(k, highlight->button->GetImage(k));
	   highlight->button->SetImage(k, img);
	  }
	  highlight = null;
	  break;
	 }
    }

Edited by Knight52, 27 July 2012 - 08:41 AM.


Sponsor:

#2 Knight52   Members   -  Reputation: 171

Like
0Likes
Like

Posted 27 July 2012 - 09:13 AM

Ah never mind. I've fixed that. It had something to do with "ItemSlot slot = *itemslot[i][j];" or passing 2 or 3 levels pointer. Sorry.

#3 SamiHuutoniemi   Members   -  Reputation: 259

Like
2Likes
Like

Posted 27 July 2012 - 10:16 AM

That usually means that you try to delete something not allocated with new.

for example:
[source lang="cpp"]int a;int* pA = &a;delete pA;[/source]
would generate that error.

Edited by SamiHuutoniemi, 27 July 2012 - 10:17 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS