I’m using interfacing Inform7 to Inform6 routines to do real-time cryptography in adventures.
After returning from the Inform6 routines and successfully showing the results, I get the following message:
[code]*** Value handling failed: impossible deallocation ***
*** Run-time problem P49: Memory allocation proved impossible.
[ The game has finished ][/code]
The following code segments show how I’m defining my variables and calling the routines.
[Define the variables.]
par_a is a number that varies.
par_b is a number that varies.
plaintext is indexed text that varies.
ciphertext is indexed text that varies.
alphabet is indexed text that varies.
To check Affine Cipher:
Now par_a is 7; [slope]
Now par_b is 17; [offset]
Now plaintext is "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; [Set to allow one to easily see the shift is working]
Now alphabet is "ABCDEFGHIJKLMNOPQRSTUVWXYZ "; [alphabet]
Now ciphertext is the Affine Encryption of plaintext using alphabet and par_a and par_b; [Determine the ciphertext]
Say "Returned from Encryption with [ciphertext].";
[Say the Affine Encryption of plaintext using par_a and par_b is ciphertext; [Say the ciphertext]]
Now plaintext is the Affine Decryption of ciphertext using alphabet and par_a and par_b; [Determine the decrypted text]
Say "Returned from Decryption with [plaintext].";
[Say the Affine Decryption of ciphertext using par_a and par_b is plaintext. [Say the decrypted text]]
[code]To decide which text is the Affine Encryption of (from_text - text) using (str_alphabet - text)and (par_a - a number) and (par_b - a number):
(- (Affine_Cipher(0, {-by-value: from_text}, {-new:indexed text},{-by-value:str_alphabet}, {par_a}, {par_b})) -).
To decide which text is the Affine Decryption of (from_text - text) using (str_alphabet - text)and (par_a - a number) and (par_b - a number):
(- (Affine_Cipher(1, {-by-value: from_text}, {-new:indexed text},{-by-value:str_alphabet}, {par_a}, {par_b})) -).
[/code]
Looks like the crypto code is working exactly as it should, but Inform7 is having trouble deallocating some of the variables at the end of the run.
It looks like the same bug as reported in http://inform7.com/mantis/view.php?id=1415
The only difference is that I’m using Inform (1.5/6.33/6L02) on a Mac OSX 10.9.4 instead of Windows.
Can anyone help me overcome this hurdle…
Am I coding something incorrectly?
Is there a better way to call the routines and avoid the issue?
If I can’t revise the code to avoid the issue, are there any known work-arounds???
ADDENDUM
I tried running the code using Glulx and got a different response:
Glulxe fatal error: Memory access out of range (3027230E)
Not sure what is being “accessed” at this point in the program, since the correct results were printed.