Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5604

Re: Memory corruption problem

From David Higton <dave@davehigton.me.uk>
Newsgroups comp.sys.acorn.programmer
Subject Re: Memory corruption problem
Date 2018-11-17 20:59 +0000
Organization Home
Message-ID <5ad68b5857.DaveMeUK@my.inbox.com> (permalink)
References <2e86dd5757.Alan.Adams@ArmX6.adamshome.org.uk> <d3ad8c64-f34e-4187-8f6c-c6cccf0b8b0f@googlegroups.com>

Show all headers | View raw


In message <d3ad8c64-f34e-4187-8f6c-c6cccf0b8b0f@googlegroups.com>
          David Buck <dbuckhome@gmail.com> wrote:

> Sounds like a classic CLOSE#0 occurring. This used to be my downfall, and
> caused the desktop font to change also. Make sure a handle is valid before
> closing it, some thing like...
> 
> If handle%>0 THEN CLOSE#handle%

Here's my offering, in the hopes that it may help someone.

I make it a golden rule to only close files by means of a PROC, never
anywhere else.  I have two styles, one to close a specific file that
is built into the PROC, and another one that closes a file whose
handle is passed in.

DEF PROCclose_input_file
REM Closes file handle input_file%
LOCAL ERROR
ON ERROR LOCAL input_file% = 0
IF input_file% <> 0 THEN
 CLOSE#input_file%
 input_file% = 0
ENDIF
ENDPROC

DEF PROCclose_file(RETURN h%)
REM Closes file handle h%
LOCAL ERROR
ON ERROR LOCAL h% = 0
IF h% <> 0 THEN
 CLOSE#h%
 h% = 0
ENDIF
ENDPROC

The above typed from memory, so E&OE.

I do a similar thing for sockets.  The difference is that socket number
0 is valid, and a closed socket is -1, so you can work out the required
changes.

Dave

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Memory corruption problem Alan Adams <alan@adamshome.org.uk> - 2018-11-16 13:15 +0000
  Re: Memory corruption problem Martin <News03@avisoft.f9.co.uk> - 2018-11-16 15:21 +0000
    Re: Memory corruption problem Alan Adams <alan@adamshome.org.uk> - 2018-11-16 15:53 +0000
      Re: Memory corruption problem Martin <News03@avisoft.f9.co.uk> - 2018-11-16 20:04 +0000
        Re: Memory corruption problem Alan Adams <alan@adamshome.org.uk> - 2018-11-16 22:38 +0000
          Re: Memory corruption problem Martin <News03@avisoft.f9.co.uk> - 2018-11-16 23:46 +0000
  Re: Memory corruption problem David Buck <dbuckhome@gmail.com> - 2018-11-16 23:15 -0800
    Re: Memory corruption problem Alan Adams <alan@adamshome.org.uk> - 2018-11-17 12:21 +0000
      Re: Memory corruption problem Alan Adams <alan@adamshome.org.uk> - 2018-11-17 13:10 +0000
        Re: Memory corruption problem Martin <News03@avisoft.f9.co.uk> - 2018-11-17 19:01 +0000
          Re: Memory corruption problem Alan Adams <alan@adamshome.org.uk> - 2018-11-17 21:04 +0000
        Re: Memory corruption problem Erik G <noreply123@xs4all.nl> - 2018-11-24 20:17 +0100
    Re: Memory corruption problem "John Williams (News)" <UCEbin@tiscali.co.uk> - 2018-11-17 12:26 +0000
    Re: Memory corruption problem David Higton <dave@davehigton.me.uk> - 2018-11-17 20:59 +0000

csiph-web