Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Strings of variable size
2004-03-11 17:27
Hoogo

Registered: Jun 2002
Posts: 102
Strings of variable size

I'm thinking about a good way to store strings of variable size. I don't have the time for a garbage collection because it should be used in a demo. The correct numbers may differ a little, but the strings have to fit to this:
-Always the same number of strings, it's an array of 700 strings
-Size is between 32 and 64 Bytes
-Usually they will be read AND changed, usually they will become bigger.
-Normally about 2 to 20 folowing strings are read/rewritten.
-A "char" has 11 bits, any combination may occur.
-This all runs until I run out of memory.

Now I tried to find a good solution for this. My favorite aproach so far, though I did not think it to the end:

-700*32 Bytes fixed strings (Its mimimum size or little above)
-A map of a few hundred 32Byte-chunks as an overflow-area. These chunks might be divided into 2. The last 3 Bits of the 32byte-chunk can tell if a half is free or used and if the whole chunk is divided or not.
-For every of the 700 strings I need a link to its overflow-area.

I hope that I waste only half of the overflow-memory, less than a quarter overall.
The most expensive thing that can happen is that a 16byte-chunk overflows and that I have to find 1 more lonely 16byte-chunk, move and relink one of them.

Anyone some suggestions about all this?

Frank/Hoogo
2004-03-12 00:21
Stryyker

Registered: Dec 2001
Posts: 465
Tried messing with fixed sized arrays? Maybe use (0) as size or another array for the size tables. No idea about speed but if you have space you can create some assembly that will copy over old values. That way the same memory is used and you reduce chances of running out of memory because of the bad memory management of variables.
2004-03-12 11:24
Hoogo

Registered: Jun 2002
Posts: 102
Oh, I was talking about assembler anyway, sorry that I did not mention that.

I do not have enough memory to give every string the maximum size. But with a variable size it will go fine for a while. Now my problem is how to store them without wasting to much room or needing a garbage collection. I'm looking for a memory management that fits my purposes.

Writing over old values will not work. My strings become longer, so normally they have to be stored at the end, leaving a big hole of unused memory. And how do I manage these holes? Keeping they adress an lenght in a list? That list will suck up my memory and will also need a kind of collection (following holes can/have to be reduced to one bigger hole).

I also thought about storing a new string always at the end and having a permanent garbage collection. When I store one string at the end, I might move 2 string as far to the beginning as possible, but that was a really bad idea and does not work at all.
2004-03-12 11:40
Stryyker

Registered: Dec 2001
Posts: 465
how about making tables of 32 bytes each. If you want more then link 2. Have a table for first and 2nd. entry used. Can be limiting but may be quicker.
2004-03-12 15:49
Hoogo

Registered: Jun 2002
Posts: 102
Hm, sounds much easier than my variation :-) I'll have some tests with that
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Harry Potthead
Majikeyric
Visage/Lethargy
curtcool
kbs/Pht/Lxt
mutetus/Ald ^ Ons
Krill/Plush
Guests online: 70
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 MWS  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.039 sec.