Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Invalid Pointer Error when i try FaddList()

Invalid Pointer Error when i try FaddList()

A PocketC native palm library offering native forms and assorted utilities

Postby r2k on Thu Feb 24, 2005 7:46 pm

Hi Joe, i'm again to deliver you an strange problem

i get this when i try to add a pointer to a list
I:\Banzai\ARM\Core\Emul68K\Src\Emul68KCommon.c, Line:1914, Invalid ptr: 31F002B8

the line is this FaddList(alumnoGrupo_POP,contador3,&materiaArr[0]);

where:
* alumnoGrupo_POP is a pop List linked to alumnoGrupo_CMB (defined integer)
* contador3 is a simple counter (integer)
* materiaArr is an one-dimension-Array with a variable wlimit (an dynamic array)

i tried to change my method to made it simpler but that doesn't works, i tried too to split my method in a lot of specialized methods but that doesn't works.

Note: i have a function that do something similar and it works perfectly, i have readed some post about the problem with the pointers and new versions of PocketC

i will post the both source codes.

first the wrong method:
Code: Select all
alumnoMateria_CMBFill(){
   int indice=0,estado=0,bandera=0;
   int contador=0,contador2=0,contador3=0;
   int limite=0,limite2=0,IDalumno=-1;
   string nombre;
   pointer datos, resultado;
   pointer materia,materiaArr;
   
   IDalumno=buscarRegistro("IDalumno",0);
   limite2=getNumMaterias(IDalumno);
   limite=DBinfo(2,0);
   if(limite2>0) resultado=Array("s,"+limite2);

   for(contador=0;contador<limite;contador++){
      DBgetrec(contador,datos);
      if(IDalumno==datos[1]){
         resultado[contador2]=datos[2];
         contador2++;
      }
   }

   nombre=nombreBD(1);
   estado=DBopen(nombre);
   limite=DBinfo(2,0);
   materia=Array("s,5");
   if(limite2>0) materiaArr=Array("s,"+(limite-limite2));
   else materiaArr=Array("s,"+limite);
   
   contador3=0;
   for(contador=0;((contador<limite) && (limite2>0));contador++){
      DBgetrec(contador,materia);
      for(contador2=0;contador2<limite2;contador2++){
         if(materia[0]==resultado[contador2]) bandera=1;
      }
      if(bandera==0){
         materiaArr[contador3]=materia[2]+"-"+materia[1];
         contador3++;
      }
      bandera=0;
   }
   
   if(limite2==0){
      contador3=0;
      for(contador=0;contador<limite;contador++){
         DBgetrec(contador,materia);
         materiaArr[contador3]=materia[2]+"-"+materia[1];
         contador3++;         
      }
   }

   FdelList(alumnoGrupo_POP,-1);
   FsetText(alumnoGrupo_CMB,"");

   if(contador3>0){
      <font color="red"><b>FaddList(alumnoGrupo_POP,contador3,&materiaArr[0]);</b></font id="red">
      FsetState(alumnoGrupo_POP,0);
      FsetText(alumnoGrupo_CMB,FgetText(alumnoGrupo_POP));
   }

   Fctl(UPDATE);
}


and the right method:
Code: Select all
alumnoMateriasFill(){
   int indice=0,estado=0,bandera=0;
   int contador=0,contador2=0,contador3=0;
   int limite=0,limite2=0;
   string nombre;
   pointer datos, resultado;
   pointer materia,materiaArr;

   limite2=getNumMaterias(buscarRegistro("IDalumno",0));
   contador2=0;
   nombre=nombreBD(1);
   estado=DBopen(nombre);
   limite=DBinfo(2,0);
   materia=Array("s,5");
   if(limite2>0) materiaArr=Array("s,"+limite2);
   else materiaArr=Array("s,"+limite);
   for(contador=0;contador<limite;contador++){
      DBgetrec(contador,materia);
      for(contador2=0;contador2<limite2;contador2++){
         if(materia[0]==resultado[contador2]){
            materiaArr[contador3]=materia[2]+"-"+materia[1];
            contador3++;
         }
      }
      bandera=0;
   }
   FdelList(gruposAlumno_LST,-1);
   if(contador3>0){
      <b><font color="green">FaddList(gruposAlumno_LST,contador3,&materiaArr[0]);</font id="green"></b>
      FsetState(gruposAlumno_LST,0);
   }
   Fctl(UPDATE);
}
r2k
 
Posts: 10
Joined: Sat Jan 08, 2005 1:51 am

Postby jstadolnik on Sat Feb 26, 2005 8:59 pm

I ran some tests of my own and FaddList ran fine for me.

My guess whould be that you all calling FaddList with the value of contador3 being larger the size of the materiaArr array. If you read off the end of an array you can get behavior like you are seeing.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA


Return to Pocket Toolbox

Who is online

Users browsing this forum: No registered users and 1 guest

cron