Now, this has to be some strange magic stuff or something.  I've got an SV
that somehow seems to overwrite itself as a result of an sv_catpv?    Here's
a bit of code  (where ST(0)/opts should be a string that's an struct option *): 

if (mapfile) {
        opts->mapfile = SvEND(ST(0));
        printf("opts->mapfile = %X\n", SvEND(ST(0)) );
        sv_catpv( ST(0), mapfile );     
        printf("Now mapfile = %s -> %s\n", mapfile, opts->mapfile); 
}
if (outfile) {
        int i;
        printf("appending outfile\n");
        opts->outfile = i =  SvEND(ST(0));
        printf("opts->outfile = %X\n", opts->outfile );
        sv_catpv( ST(0), outfile );     
        printf("appended ST so end is now %X\n", SvEND(ST(0)));
        printf("Now mapfile = %s and opts->outfile = %X\n", (char *)i, opts->outfile); 
}

where the struct in question is defined by 

typedef struct options t_opts;
...
t_opt opts = ($type) sv_grow( $arg, sizeof(*$var) );
..where..
struct options 
{
  int cities;
  int gridlines;
  double zoom;
  double xrot;
  double yrot;
  double zrot;
  char* mapfile;
  char* outfile;
  char* colorfile;
  BIT32 desired_categories;
  BIT32 desired_continents; 
};

And this is what the results are of calling newOptions :

opts->mapfile = 80DC538
Now mapfile = /usr/local/share/rmap/earth.rez -> /usr/local/share/rmap/earth.rez
appending outfile
opts->outfile = 80DC557
appended ST so end is now 80DC567
Now mapfile = /tmp/outfile.gif and opts->outfile = 666967


How is it that opts->outfile goes from 80DC557 to 666967
when all i'm doing is adding onto the end of the SV?  Anyone?

thnx in advance,
-Reza
 

Reply via email to