osek null pointer usage

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

osek null pointer usage

Postby epokh » Sat Feb 14, 2009 3:07 pm

Hi takashi,
I would like to know how can I check if a pointer is null or not,
for instance this routine:
Code: Select all
void lif_init(Lif *ptr,float R,float C,float deltaT)
{
   if(ptr!=NULL)
   {
      float tau=R*C;
      ptr->alfa=(tau/(tau+deltaT));
      ptr->beta=(R*deltaT)/(tau+deltaT);
      ptr->spike=0;
      ptr->u[0]=0.0;
      ptr->u[1]=0.0;
      ptr->Th=1.0;
   }
}



is not compiling neither with NULL neither with null.
Can you give me some example?
Cheers.
epokh
Novice
 
Posts: 26
Joined: Wed Feb 21, 2007 5:46 pm

Re: osek null pointer usage

Postby takashic » Sun Feb 15, 2009 11:36 pm

epokh wrote:Hi takashi,
I would like to know how can I check if a pointer is null or not,
for instance this routine:
Code: Select all
void lif_init(Lif *ptr,float R,float C,float deltaT)
{
   if(ptr!=NULL)
   {
      float tau=R*C;
      ptr->alfa=(tau/(tau+deltaT));
      ptr->beta=(R*deltaT)/(tau+deltaT);
      ptr->spike=0;
      ptr->u[0]=0.0;
      ptr->u[1]=0.0;
      ptr->Th=1.0;
   }
}



is not compiling neither with NULL neither with null.
Can you give me some example?
Cheers.


Please look at DynamicMemory Test sample in nxtOSEK.
Code: Select all
/* dynamicMemoryTest.c */
#include <stdlib.h>
...
mem[i] = (CHAR *)malloc(strlen(str[i]));
if(mem[i] == NULL) {
 display_clear(0);
 display_goto_xy(0, 0);
 display_string("HEAP MEMORY: Err");
 display_update();
}


I think that you would need to add #include <stdlib.h>.

takashic
takashic
Novice
 
Posts: 32
Joined: Mon May 21, 2007 2:22 am


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron
more stuff