🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4935

Re: Clever way to deal with this?

#4935
From: MARK
Date: Tue, 13 Feb 1990 05:32
33 lines
1316 bytes
I'm not sure this will work, because I have never tried it myself in
a language like Modula-2, but I think that this (or very close to
this) will take care of your problem for you:

TYPE
    pRec = POINTER TO Rec;
    Rec = RECORD
        NumChars : CARDINAL;
        Chars : ARRAY [ 0..MAX( CARDINAL ) ] OF CHAR;
    END;

VAR
  Data : pRec;
  Num : CARDINAL;

BEGIN
    Num = { Some cardinal number };
    ALLOCATE( pRec, SIZE( Num ) + Num );   (*  assuming CHARs are 1 byte *)
 ... etc.

You have to be careful not to do the following:
1)  Don't have Rec as the type of any parameter, but always access
    it through the dereferencing of the pointer.
2)  Don't rely on ANY Modula-2 string procedures, but always use
    NumChars for the integrity check.

Hope this works for you,

Mark Morrell
Software Specialist
Western Illinois University

MARK @ ECNCDC
Technical Details
Message-ID: <INFO-M2%90021302490640@UCF1VM.BITNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ECNCDC.BITNET!MARK

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ECNCDC.BITNET!MARK
From: MARK@ECNCDC.BITNET
Newsgroups: comp.lang.modula2
Subject: Re: Clever way to deal with this?
Message-ID: <INFO-M2%90021302490640@UCF1VM.BITNET>
Date: 13 Feb 90 05:32:00 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@PSUVM.PSU.EDU>
Organization: The Internet
Lines: 33