[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::languages

Title:Languages
Notice:Speaking In Tongues
Moderator:TLE::TOKLAS::FELDMAN
Created:Sat Jan 25 1986
Last Modified:Wed May 21 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:394
Total number of notes:2683

273.0. "Dynamic Memory Question" by PDV01::MEDONI () Thu Mar 29 1990 08:11

    
    Hi guys
    
    I'm developing a kind of interpreter and I was asking myself which
    is the best way to manage numerical and string variables.
    I mean which is the best in C language:
    
    1 - Allocate a big buffer for variables and keep moving inside this
        buffer with pointers and memmove. For example allocating at
        the beginning of the program a large buffer with (char*)malloc(65536)
        and storing there any variable I got from the input stream.
    
    2 - Allocate a small buffer (with malloc) for each variable declaration
        I got from the input stream. In this way my variables are stored
        in many  different buffers allocated run-time by the interpreter.
    
    
    I really like to work with dynamic memory allocation but my fear
    is to stress the system keep asking for memory allocation. Is it
    not better to allocate a big buffer at the beginning at work inside
    it ?
    
    
    Thanks for helping me !!!
    
    Ciao
    Luciano
    
    
    
T.RTitleUserPersonal
Name
DateLines
273.1TLE::FELDMANDigital Designs with PDFThu Mar 29 1990 11:2417
You may want to ask in the notes files of those languages that are already
interpretive, to see how they do things.  Languages that come to mind are
BASIC, APL, and TPU.

If this is a VMS project, you may even be able to use existing interpreters, and 
save yourself the trouble of writing yet another new one.  TPU has a callable 
interface, the others may as well.  If this is an Ultrix project, there are a
number of tools that might meet your needs.  Then again, you may have unique
needs that can't be solved by anything that already exists.

The fact that you're progamming in C isn't directly relevant.  The answer
would be the same if you were programming in Bliss or Pascal.  The answer might
be different if you were 100% sure you were only going to target VMS, because
of the power in the VMS RTL memory management routines.  These days, there 
aren't too many projects that are that sure about their future target.

   Gary
273.2thanks GaryPDV01::MEDONIThu Apr 05 1990 08:482