Click here to Skip to main content
16,011,784 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
22-Jan-01 4:23
suss22-Jan-01 4:23 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
Erik Funkenbusch22-Jan-01 13:04
Erik Funkenbusch22-Jan-01 13:04 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
James R. Twine30-Jan-01 10:15
James R. Twine30-Jan-01 10:15 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
Erik Funkenbusch31-Jan-01 13:22
Erik Funkenbusch31-Jan-01 13:22 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
James R. Twine2-Feb-01 7:17
James R. Twine2-Feb-01 7:17 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil Pin
Erik Funkenbusch18-Jan-01 13:06
Erik Funkenbusch18-Jan-01 13:06 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil Pin
Walter Gildersleeve18-Jan-01 20:07
Walter Gildersleeve18-Jan-01 20:07 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil Pin
Jim Howard22-Jan-01 8:46
Jim Howard22-Jan-01 8:46 
Many Windows functions require a standard LPTSTR, such as Registry and file functions (some file operations are not possible using CFile) and I see nothing wrong with using a CString allocated buffer for them, then using CString to manipulate the data.

Of course we all agree (I think) that it's ok to pass character data into a function using CString's implied "const char*" cast. If a function wants to write into a buffer, I make a real buffer and pass it in to them. I think this is a much safer coding approach. I know you and I can keep our calls to release buffer straight, but what happens when that shifty looking guy standing over there modifies our code? I don't know about you, but he looks lazy to me and I bet he hasn't carefully studied the CString docs. Maybe he's used to using (insert name of any other string class in the world), and makes the childish asumption that like them, CString won't just hand him a pointer that has a ticking time bomb attached to it. I trust you to keep it straight, but I don't trust him.

Remembering to call ReleaseBuffer is no more a problem than having to remember to call delete or free on dynamicly allocated memory (which you'd have to do for the functions I mention, since you wouldn't know at runtime how much memory they take until you query them). In my opinion, once you've called GetBuffer(), you no longer have CString object available to you. Forget it exists until you've called ReleaseBuffer.

You have put your finger on the essential evil of GetBuffer much better than I. You're exactly correct! Once you call GetBuffer you no longer have an object! GetBuffer defeats the whole purpose of object oriented programming!

I have nothing more to say on this subject, excuse me while I get back to a "goto" argument on another forum. Blush | :O

Jim
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil Pin
Erik Funkenbusch22-Jan-01 13:39
Erik Funkenbusch22-Jan-01 13:39 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil Pin
Sven Axelsson25-Jan-01 3:23
Sven Axelsson25-Jan-01 3:23 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil Pin
Erik Funkenbusch25-Jan-01 11:55
Erik Funkenbusch25-Jan-01 11:55 
QuestionHow to remove Console App's button from Taskbar? Pin
16-Jan-01 14:24
suss16-Jan-01 14:24 
QuestionWhy does New Class dialog not allow custom classes? Pin
16-Jan-01 14:18
suss16-Jan-01 14:18 
AnswerRe: Why does New Class dialog not allow custom classes? Pin
Christian Graus16-Jan-01 16:22
protectorChristian Graus16-Jan-01 16:22 
GeneralResizeing View programatically... Pin
16-Jan-01 8:45
suss16-Jan-01 8:45 
GeneralRe: Resizeing View programatically... Pin
Christian Graus16-Jan-01 9:12
protectorChristian Graus16-Jan-01 9:12 
GeneralRe: Resizeing View programatically... Pin
16-Jan-01 10:44
suss16-Jan-01 10:44 
GeneralRe: Resizeing View programatically... Pin
Christian Graus16-Jan-01 11:37
protectorChristian Graus16-Jan-01 11:37 
GeneralRe: Resizeing View programatically... Pin
16-Jan-01 12:09
suss16-Jan-01 12:09 
GeneralRe: Resizeing View programatically... Pin
Christian Graus16-Jan-01 18:21
protectorChristian Graus16-Jan-01 18:21 
GeneralRe: Resizeing View programatically... Pin
16-Jan-01 23:37
suss16-Jan-01 23:37 
GeneralCPropertyPage in Wizard Mode does not call OnKillActive() Pin
16-Jan-01 5:30
suss16-Jan-01 5:30 
GeneralRe: CPropertyPage in Wizard Mode does not call OnKillActive() Pin
16-Jan-01 18:02
suss16-Jan-01 18:02 
GeneralRe: CPropertyPage in Wizard Mode does not call OnKillActive() Pin
16-Jan-01 22:20
suss16-Jan-01 22:20 
GeneralMenu handle Pin
subir talukder16-Jan-01 4:13
subir talukder16-Jan-01 4:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.