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()
Page 1 of 1

PostPosted: Thu Feb 24, 2005 7:46 pm
by r2k
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);
}

PostPosted: Sat Feb 26, 2005 8:59 pm
by jstadolnik
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