F
Felix Kater
Hi,
in some cases like dynamic memory allocation I find it convenient to
(ab-)use for() or while() like this:
/* (allocate memory) */
for(;{ /* alternatively: while(TRUE){ */
/* (other code) */
break;
}
/* (free memory) */
The reason to do that is to remind the programmer who might not be me
not to forget things (like freeing memory) when inserting code later,
keep the order of commands (don't free too early) etc.
Two questions:
Are there generally better ways to do that?
Are there reasons to prefer one of the two ways (for vs, while) ?
Felix
in some cases like dynamic memory allocation I find it convenient to
(ab-)use for() or while() like this:
/* (allocate memory) */
for(;{ /* alternatively: while(TRUE){ */
/* (other code) */
break;
}
/* (free memory) */
The reason to do that is to remind the programmer who might not be me
not to forget things (like freeing memory) when inserting code later,
keep the order of commands (don't free too early) etc.
Two questions:
Are there generally better ways to do that?
Are there reasons to prefer one of the two ways (for vs, while) ?
Felix