Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Miscellaneous > Archive > CtP2-Creation/AI/Mods/Scenarios-Archive > Reallocating memory for arrays
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
ahenobarb is offline ahenobarb
Prince

Nov 2001
time: 05:25
  Old Post 16-01-2003 23:16
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Reallocating memory for arrays Browse Apolyton AD-FREE

I have a question about freeing up memory from an array.

Situation: You have an array that contains information valid for a single turn only (say 12 values). The next turn you want to put new information in the array, but you do not have as many values to put into the array as you did last turn (say 8 values). You reinitialize the array so that all the old values are replaced with 0, then put the new values into the array. You request the size of the array and CTP2 tells you the size of the array is 12, because you have simply replaced the 12 values in the first run with 0's. To get an accurate count of the size of the array, you have to subtract the number of slots with 0s in them from the size of the array.

Is there a way in SLIC to tell CTP2 to release the unused portion of the array, so you can get an accurate reading of the size of the array without the need for an equation?

Or, once memory has been allocated for an array, that array remains the same size whether you need that information or not?

Last edited by ahenobarb on 17-01-2003 at 03:14

Martin Gühmann is offline Martin Gühmann
Emperor
Berlin, Germany
Mar 2001
time: 06:25
Post  Old Post 17-01-2003 02:13 Visit Martin Gühmann's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Increase the size of your Attachments

Unfortunatly I don't know a way to free the unused space of the Array. Actual if it is initialed it is initialized until slic is reloaded, so if you write something into an array in an event handler and the event handler is executed again then the array contains the same information as in the call before, it is not reinitialized therefore you have to put every value back on zero on your own.

-Martin

ahenobarb is offline ahenobarb
Prince

Nov 2001
time: 05:25
  Old Post 17-01-2003 03:17
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Tired of ads?

quote:
Originally posted by Martin Gühmann
Unfortunatly I don't know a way to free the unused space of the Array. Actual if it is initialed it is initialized until slic is reloaded, so if you write something into an array in an event handler and the event handler is executed again then the array contains the same information as in the call before, it is not reinitialized therefore you have to put every value back on zero on your own.

-Martin


I believe you are correct Martin. It seems that arrays can only increase in size (that is unless you limit the size when it is declared), but there is no way to decrease their size.

I wonder what happens to the array size in that case above if you were to stop the game and then restart it? Would it have a size of 8 or 12?

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:25
  Old Post 20-01-2003 22:13 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton, pre-order Civilization IV

With c++ if you allow a array to continue to grow beyond the amount you declared it at you run the risk of errors as the system wipes all data on the memory to store the data in the increased array.

I hope for all our sakes that this is not true of slic

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:25
  Old Post 21-01-2003 01:57 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton buy from Amazon

No it's not.

And if you quit the game, all memory is (or should be, depending on how well they programmed it) given back to the system, so if you restart it, it would get the same size as the previous time.

Personally, I suspect non-delimited arrays in SLIC are in fact linked lists.

The Big Mc is offline The Big Mc
King
Of the universe / England
Oct 2001
time: 05:25
  Old Post 22-01-2003 14:41 Visit The Big Mc's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton

ok.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:25.
Apolyton Time is 00:25.
    top of page
Rate This Thread:
archivepost
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0346 seconds (86.63% PHP - 13.37% MySQL) with 31 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net