Free memory allocated from a function
Free memory allocated from a function
Hi,
I'm still working on Xplora, but I've see that the memory is not completely free when returning from the Text editor, so there's a solution to free all the memory allocated by this function or I can only try to improve the code to free the allocated memory?
Thanks in advance
I'm still working on Xplora, but I've see that the memory is not completely free when returning from the Text editor, so there's a solution to free all the memory allocated by this function or I can only try to improve the code to free the allocated memory?
Thanks in advance
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
it is better to use switch (when you can) instead of many if's. It makes your code neat and clear. I don't know about speed but it might be the same.
Remember that if's can make things VERY slow. Example:
It executes 2 functions:
strlen
strcmp
the actual if does not slow down but its conditions can slow down your program.
Remember that if's can make things VERY slow. Example:
Code: Select all
char charv[200];
sprintf(charv, "my name is blablabla");
if (strlen(charv) >= 100 && strcmp(charv, "my name is blablabla") == 0)
{
// etc
}
strlen
strcmp
the actual if does not slow down but its conditions can slow down your program.
-
- Posts: 31
- Joined: Sun Mar 23, 2008 2:16 am
- Contact:
Thats pretty much the same as running two if statements in the assembly.Pirata Nervo wrote:it is better to use switch (when you can) instead of many if's. It makes your code neat and clear. I don't know about speed but it might be the same.
Remember that if's can make things VERY slow. Example:It executes 2 functions:Code: Select all
char charv[200]; sprintf(charv, "my name is blablabla"); if (strlen(charv) >= 100 && strcmp(charv, "my name is blablabla") == 0) { // etc }
strlen
strcmp
the actual if does not slow down but its conditions can slow down your program.
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am
-
- Posts: 31
- Joined: Sun Mar 23, 2008 2:16 am
- Contact:
Exactly...Pirata Nervo wrote:I know but we were not talking about that, we were talking about the "slow down".
The number of conditions (n) in a single if can also be represented as n if statements.
The actual if CAN cause slowdowns, as it is an instruction, but its so small.
Your example is terrible btw.
-
- Posts: 409
- Joined: Tue Oct 09, 2007 4:22 am