based on the fact that the crash never seemed to have happened with default screen resolutions and also inspired by the only other getmem usage in the code I came up with this simple solution which seems to work just fine.
authorsheepluva
Thu, 15 Sep 2011 09:19:56 +0200
changeset 5911 4a28d0ae9624
parent 5910 c9a4de51b5a0
child 5912 d31eba29e706
based on the fact that the crash never seemed to have happened with default screen resolutions and also inspired by the only other getmem usage in the code I came up with this simple solution which seems to work just fine. I do not understand why getmem seems to need this, but well - feel free to explain.
hedgewars/uMisc.pas
--- a/hedgewars/uMisc.pas	Thu Sep 15 03:17:23 2011 +0200
+++ b/hedgewars/uMisc.pas	Thu Sep 15 09:19:56 2011 +0200
@@ -32,7 +32,7 @@
 procedure freeModule;
 
 implementation
-uses typinfo, sysutils, uVariables;
+uses typinfo, sysutils, uVariables, uUtils;
 
 procedure movecursor(dx, dy: LongInt);
 var x, y: LongInt;
@@ -74,7 +74,7 @@
 ScreenFadeValue:= sfMax;
 ScreenFadeSpeed:= 5;
 
-size:= cScreenWidth * cScreenHeight * 3;
+size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 3;
 p:= GetMem(size);
 
 // memory could not be allocated