Reading what you're all saying makes sense. I feel stupid for thinking it was a good idea. I'm looking into those links ChaosEngine. The reason I wanted to delete the non-heap variable was to save me having to add in an extra assignment and conditional but I suppose that's just OTT efficiency. I can't help myself, despite not even knowing how to pull it off properly.
that was a typo I think ancient dragon, or a copio maybe. What I have now may not be much better:
env_qs is a char * at class scope. ~CGI() deletes it.Code:void CGI::accept_post() { if( getenv("CONTENT_LENGTH") ){ char *endptr; env_cl = (int)strtol(getenv("CONTENT_LENGTH"), &endptr, 10); } if( env_cl > 1 && env_cl <= MAX_BUF_SIZE ){ // leave in the '1' env_qs = new char[env_cl+1]; // FREE-STORE VARIABLE for( int i=0; i< env_cl && env_qs[i] != EOF; i++ ) { env_qs[i] = std::cin.get(); } env_qs[env_cl] = 0x00; this->unencode( env_qs ); }else{ this->header(); std::cout<< "Don't do that."; } }
Daved, you've almost convinced me to use strings, but I don't like either how the c-string functions don't work on them - I'm guessing calling c_str() and casting to a char * every time you need one is highly inefficient (guessing being the key word) - or how few people seem to use them. It makes me a bit wary. Shaky knees and all.



LinkBack URL
About LinkBacks




Want to add some