Author Topic: C BASIC - Traditional  (Read 1578 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 1677
    • ScriptBasic Open Source Project
C BASIC - Traditional
« on: February 04, 2014, 11:31:35 AM »
I have taken the traditional version of C BASIC as far as I can using #define. I need a memory / string manager and a supporting library of functions to go with them. I know Charles is busy doing a C makeover with O2 and isn't ready yet to migrate that effort into the C BASIC realm.

I'm moving forward using Peter Verhas's MyAlloc thread safe memory manager used in ScriptBasic and the string functions from SB. I will try to roll in the work Charles did with the DLLC project into the C BASIC project where appropriate.

Quote from: Peter Verhas
The MyAlloc memory management module is to help the programmer to avoid crating memory leaking applications. When allocating dynamic memory via malloc you have to release it using free. Old programs do not care too much about freeing the memory as the task was done by the operating system, whenever the process ended. Nowadays single process, multithread applications should release memory.

Using the package MyAlloc you first create a memory segment. A memory segment is a logical entity. Whenever you allocate a new piece of memory you have to specify what memory segment you want to use for it. MyAlloc does not preallocate memory, just keeps track of the memory pieces that were allocated for the segment. Whenever you want to get rid of all memories allocated for a segment you can release them all with a single function call without calling free for each malloced memory piece.

You can release memory segments, merge them together, release memory pieces allocated to a segment and so on.

The module is GNU LGPL and is part of the ScriptBasic interpreter package.