Run time error 3 - Stack Error - is there a pragma I need?
In war3ft this line is giving me a stack error:
new szEachLine[150][128]; Is there a pragma I can use so my plugin is given more memory? I'm salty... TY, Josh |
Please tell me that line isn't in a function.
I don't want to have to hurt you. |
haha yea its in a function.. is that the problem?
Code:
|
not only is there no need to waste memory, you should use the 'static' keyword on large local variables.
|
Code:
compiled fine with 0 errors and 0 warnings. not tested, but should work edit: i had an mistake in the code *fixed* |
You see, that's a lot of memory. 150*128*4 = 76800 = 75 kB on the stack... Should be avoided when possible (although the compiler _should_ have computed the estimated stack size correctly in this case I think.. hmm.)
Instead, you could only hold a buffer for one line and process them on the fly ( in the body of the loop which has read_file in its condition ). This way you also wouldn't need to re-evaluate the length of each line (read_file fills it in the last parameter). I was also a bit surprised that you reserved a 128 byte buffer for each line and then told read_file to return 31 characters at max. You may want to use a constant for the line buffer length so you don't have to change it in two places (but then do constant+1 in the buffer declaration). You may also want to try using the new file natives. Also, the // Semicolon before module name found comment was misleading I'm afraid. Well, my thoughts. |
Ohayo Geesu-chan! :D
There are many better ways to do this! :D first off you should start by not using a predefined path to the module.ini; using the stocks provided by amxx is much cleaner and portable! second off this could easily be accomplished with a simple read and if statement instead of thatconvoluted mess ill post an example later from mai pluginz |
OK I have it working fine now...
Suggestions? Besides using the amxx natives to get the filename :P Code:
|
lol, sometimes i shout but no one seems to hear...
My suggestions are still the same. Specifically, don't use that much memory. Do one line at a time. Read, process, write. This is even less code because write_file overwrites the line you tell it to overwrite. Unless I am missing something crucial, there's really no need to waste 75 kB of memory on this. And if I am, you could at least be so kind and point it out to me. Thank you. |
PM are u referring to use like fopen/fseek/fputc?
I tried this initially, but I wasn't able to successfully do it, so I switched to this way... O shit I think I just realized it.. since u specify the line number in read_file/write_file... LOL yea ur right, I am retarded, thanks :) |
| All times are GMT -4. The time now is 05:00. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.