ts-7000
[Top] [All Lists]

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

To:
Subject: Re: [ts-7000] Re: Segmentation Faults with Arrays greater than 64kB on TS-7260
From:
Date: Wed, 04 Jul 2007 20:38:06 -0400
>>      bin[x][y] = 0;
>
>don't you mean bin[x]->[y] ? after all, this is a pointer to an array of 

No, the original is correct.  bin[x]->[y] is not legal syntax.

When you have a pointer, you can use it in a few different ways:

Suppose you have "char *p;"

*p is the value at the address that p points at

p[x] treats the address in p as the base of an array, and extracts
element x.  p[0] is the same thing as *p.  

p[x] is the same as *(p+x) but remember that x is multiplied by the size of the
data type to get a real address.  So, if you have "int *p", p[0], p[1], etc
are the successive integers in the array.

p->y is a structure reference.  y can only be a field name from the structure.
It cannot be an expression.


So, what we have here is "unsigned char **bin;"

The type of bin is unsingned char **.

The type of bin[x] is unsigned char *.  It is element x of the array of
pointers.

The type of bin[x][y] is unsigned char.  It is element y of the array
based at the address stored in bin[x].


>> 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??

I don't see anything obviously wrong with the code snippet.  The symptoms
described here are typical of something going wrong somewhere else and
corrupting the pointers in the array.

Mark S.



 
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