ts-7000
[Top] [All Lists]

[ts-7000] Re: Segmentation Faults with Arrays greater than 64kB on TS-72

To:
Subject: [ts-7000] Re: Segmentation Faults with Arrays greater than 64kB on TS-7260
From: "geoffveale" <>
Date: Wed, 04 Jul 2007 04:20:21 -0000
Thanks for all the responses. You have given me a lot to think about.
The applicable code I am using looks similar to below. The array being
used is a 2D array and I used a routine I found on the internet to
create the array using malloc. Any further comments that might show
problems would be appreciated. The code shown runs most of the time
without problems. I have never had a crash during creation of the
array of during initialisation. Problems (seg. faults) seem to happen
at later stages after the array has been used a few times. Perhaps the
problem is in another area and the array is an easy target (because of
the size) for another code messing with the memory??

Geoff Veale


#define oops(s) { perror((s)); exit(EXIT_FAILURE); }
#define MALLOC(s,t) if(((s) = malloc(t)) == NULL) { oops("error:
malloc() "); }

unsigned char **bin;


void main(void){
   various code..
   
   my_subroutine();

   return;
}

void my_subroutine(void){ 

  MALLOC( bin, sizeof( unsigned char *) * 72);

  for (i = 0; i < 72; i++) {
  MALLOC( bin[i], sizeof(unsigned char) * 4096);
  }
  
  //fill array with zeros
  for ( x = 0; x < 72 ; x++){
    for ( y = 0; y < 4096; y++){
        bin[x][y] = 0;
    }
  }


  other code..

  return;
}







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU