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

C / C++ / MFC

 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
19-Jan-01 6:28
suss19-Jan-01 6:28 
GeneralRe: Jihad! GetBuffer/ReleaseBuffer considered Evil - Part II Pin
Erik Funkenbusch19-Jan-01 19:36
Erik Funkenbusch19-Jan-01 19:36 
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 
Your argument doesn't make a lot of sense to me.

All of the things you argue about (having to remember how long your string is, or if it's null terminated) apply equally to a seperate buffer as well.

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.

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. The memory returned by GetBuffer is no different from memory returned by new or malloc and requires the same care you would use for new or malloced memory. There are no "land mines" that are different from newd memory, and there is no catastrophe waiting to happen that's different from managing memory allocated by new.

Is your argument that you should use CStrings own functions for string operations? If so, I agree, but I do not agree with using a seperate buffer when you need to write to a standard C character array.


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 
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 

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.