Re: "Flex memory error" woes
- From: Mr John FO Evans <mijas@xxxxxxxxxxxxxxxxx>
- Date: Mon, 07 Nov 2005 00:48:54 BST
In article <na.9aa3334dc5.a80520hsdawson@xxxxxxxxxxxx>, Howard Dawson
<hsdawson@xxxxxxxxxxxx> wrote:
> Anyone know what kind of failure usually causes this message or how I can
> get any further, as the error message is not very helpful and the program
> exits immediately on clearing it?
I had a similar problem with 'alloc' and free. You need to keep a very
careful check that a block of memory has actually been allocated before you
either free it or change it's size. To make absolutely sure I added code
which kept all allocated block pointers in an array and before
deleting/changing them I checked that there was a pre-recorded sensible
address at that location. (not forgetting to update the array! the pointer
may(will) change when the size is changed)
If it finds an error you can then call 'werr' or something similar to tell
you where the problem lies.
I also make a point of using 'sizeof' to check the size of anything I am
storing, rather than calculating it from the contents. (PS dont forget
to allow for string terminators).
It is symptomatic of bugs like this that they often cause problems much
later in the program - thus masking their source and making the hair tearing
effect rather more serious!!
NB I do let allocated arrays hold pointers - it seems to work although I
cannot see how!!!
NNB Can anyone provide an up to date description of the operation and
limitations of flex and alloc and the relationship between them? The only
description I know is in the old Acorn 'C' manual.
John
--
_ _________________________________________
/ \._._ |_ _ _ /' Orpheus Internet Services
\_/| |_)| |(/_|_|_> / 'Internet for Everyone'
_______ | ___________./ http://www.orpheusinternet.co.uk
.
- Follow-Ups:
- Re: "Flex memory error" woes
- From: Steve Fryatt
- Re: "Flex memory error" woes
- From: Erik Groenhuis
- Re: "Flex memory error" woes
- References:
- "Flex memory error" woes
- From: Howard Dawson
- "Flex memory error" woes
- Prev by Date: Re: Scroll wheel support
- Next by Date: Re: "Flex memory error" woes
- Previous by thread: Re: "Flex memory error" woes
- Next by thread: Re: "Flex memory error" woes
- Index(es):
Relevant Pages
|