About Store Forum Documentation Contact



Post Reply 
Memt strange behavior
Author Message
Houge Offline
Member

Post: #1
Memt strange behavior
Hi, I faced a problem with Memt, App is crashing. Here's the code to reproduce:

Code:
/******************************************************************************/
struct keeper
{
private:
    Memt<Int> _values;
}

Meml<keeper> values;

/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.flag = APP_BREAKPOINT_ON_ERROR;
}
/******************************************************************************/
bool Init()
{
   REP(10)values.New();
  
   MREP(values)
   {
       values.remove(i);
   }
  
   return true;
}
/******************************************************************************/
void Shut()
{ }
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   return true;
}
/******************************************************************************/
void Draw()
{
   D.clear(TURQ);
}
/******************************************************************************/

If re replace Memt with Memb, it works fine.
(This post was last modified: 09-02-2019 03:31 AM by Houge.)
09-01-2019 10:17 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Memt strange behavior
please look at MREP macro definition.
You want to use SMREP in this case.

Also Memt is not recommended for permanent storage, but temporary storage inside functions.
09-02-2019 03:45 AM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #3
RE: Memt strange behavior
Oh, thanks, I didn't notice that. But why does it work with Memb then? Or it's just luck? smile
(This post was last modified: 09-02-2019 03:47 AM by Houge.)
09-02-2019 03:47 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Memt strange behavior
You can call it luck wink
09-02-2019 03:52 AM
Find all posts by this user Quote this message in a reply
Post Reply