• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Perl or Python - Batch Script

So my project for writing a dynamic memory allocator for school is complete.

As of right now, we are testing to find:
A.) How many free-list
B.) The default MAX_SIZE for each free-list

Is there anyway someone can help me write a perl or python script that can change the '#define' in the .c files appropriately to test each case?

Thanks,
-Kevin (Gamingphreek)
 
Sounds like an ugly hack. D: Can you change the #define-d constant to a global variable?
 
No need for Perl/Python. Use sed.

sed -i 's/#define blah/#define newblah/' *.c

May need to escape some things, not entirely sure. Anyway, play around with it and it should work pretty easily.
 
No need for Perl/Python. Use sed.

sed -i 's/#define blah/#define newblah/' *.c

May need to escape some things, not entirely sure. Anyway, play around with it and it should work pretty easily.

Woah! I have never heard of sed. I will look into it though!

But, in order to run the code, then change with sed, then run, etc... I'll need to write a BASH, Perl, or Python script correct?

-Kevin
 
gcc will allow you to pass as command line arguments various stuff to define, too. Try -D'MYVAR="foo"'

its equivalent to:
#define MYVAR "foo"

... except that you can specify it from the command line instead of in the source.
 
gcc will allow you to pass as command line arguments various stuff to define, too. Try -D'MYVAR="foo"'

its equivalent to:
#define MYVAR "foo"

... except that you can specify it from the command line instead of in the source.

Ahh I knew I had used something in gcc before like that.

I think a simply BASH script with a ton of different values here should give me a good idea of what values provide the best performance.
 
Back
Top