- why not use naked delete ? - 6 Updates
- :thread...too little, too late? - 1 Update
- Interview question for Bloomberg in NYC - 1 Update
- Islam prohibited women to be Unveiled....why? - 1 Update
Luca Risolia <luca.risolia@linux-projects.org>: Dec 30 04:10AM +0100 Il 29/12/2014 18:37, Lynn McGuire ha scritto: > We use new and delete a lot in our base classes since we are memory > constrained in the Win32 environment. std::unique_ptr has been designed so that it can take the same size as a pointer by default, isn't this the case for Win32? |
legalize+jeeves@mail.xmission.com (Richard): Dec 30 04:29AM [Please do not mail me a copy of your followup] Lynn McGuire <lmc@winsim.com> spake the secret code >We use new and delete a lot in our base classes since we are memory >constrained in the Win32 environment. By "memory constrained" am I to infer you are talking about stack space? Why naked new and not std::unique_ptr<> or some sort of container? -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Lynn McGuire <lmc@winsim.com>: Dec 30 03:32PM -0600 On 12/29/2014 10:29 PM, Richard wrote: >> constrained in the Win32 environment. > By "memory constrained" am I to infer you are talking about stack > space? We run out of Win32 space if we are not careful. Probably heap space since some of our datasets go over one GB. Things are better not though since we started compressing strings in memory. > Why naked new and not std::unique_ptr<> or some sort of container? This code was written over a decade ago and works well. Never rewrite code that is working well just to use new coding features. Lynn |
"Öö Tiib" <ootiib@hot.ee>: Dec 30 02:13PM -0800 On Tuesday, December 30, 2014 11:32:33 PM UTC+2, Lynn McGuire wrote: > > Why naked new and not std::unique_ptr<> or some sort of container? > This code was written over a decade ago and works well. Never rewrite > code that is working well just to use new coding features. There is difference between writing: "We used new and delete a lot in our base classes that we wrote over decade ago." Or: "We use new and delete a lot in our base classes since we are memory constrained in the Win32 environment." First is common, lot of people did it over decade ago. Second is intriguing because writing naked 'new' and 'delete' in modern C++ adds complexities (and so defects) but does not save resources. |
woodbrian77@gmail.com: Dec 30 02:20PM -0800 On Tuesday, December 30, 2014 3:32:33 PM UTC-6, Lynn McGuire wrote: > not though since we started compressing strings in memory. > > Why naked new and not std::unique_ptr<> or some sort of container? > This code was written over a decade ago and works well. Never rewrite code that is working well just to use new coding features. I disagree with that advice, but in this case you might be better off sticking with new and delete. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
Lynn McGuire <lmc@winsim.com>: Dec 30 05:10PM -0600 On 12/30/2014 4:13 PM, 嘱 Tiib wrote: > First is common, lot of people did it over decade ago. Second is > intriguing because writing naked 'new' and 'delete' in modern C++ > adds complexities (and so defects) but does not save resources. So how would you implement this class without using new? Here is the class and constructor using a reference value: class DesValue : public ObjPtr { public: int datatype; // Either #Int, #Real, or #String. int vectorFlag; // Flag indicating value contains an Array. int optionListName; // name of the optin list item int * intValue; // Either nil, an Int, a Real, a String, or an Array thereof. double * doubleValue; string * stringValue; vector <int> * intArrayValue; vector <double> * doubleArrayValue; vector <string> * stringArrayValue; unsigned char * compressedData; unsigned long compressedDataLength; vector <unsigned long> uncompressedStringLengths; std::string * uncompressedString; int isTouched; // Flag indicating if value, stringValue, or units have been modified since this DesValue was created. Set to true by setValue, setString, setUnits, and convertUnits. int isSetFlag; // Flag indicating whether the contents of the DesValue is defined or undefined. If isSet is false, getValue returns nil despite the contents of value, while getString and getUnits return the empty string despite the contents of stringValue and units. int unitsValue; // current string value index in $UnitsList (single or top) int unitsValue2; // current string value index in $UnitsList (bottom) string errorMessage; // message about last conversion of string to value string unitsArgs; // a coded string of disallowed units public: // constructor DesValue (); DesValue (const DesValue & rhs); DesValue & operator = (const DesValue & rhs); // destructor virtual ~DesValue (); virtual DesValue * clone () { return new DesValue ( * this); } ... } DesValue::DesValue (const DesValue & rhs) { datatype = rhs.datatype; vectorFlag = rhs.vectorFlag; optionListName = rhs.optionListName; if (rhs.intValue) { intValue = new int; * intValue = * rhs.intValue; } else intValue = NULL; if (rhs.doubleValue) { doubleValue = new double; * doubleValue = * rhs.doubleValue; } else doubleValue = NULL; if (rhs.stringValue) { try { stringValue = new string; * stringValue = * rhs.stringValue; } catch (std::bad_alloc &ba) { char msg [1024]; sprintf_s (msg, sizeof (msg), "A memory error has occurred that could not be handled.\n" "Please try the operation again.\n\n" "Message: %s\n" "Size: %d bytes", ba.what (), rhs.stringValue -> size ()); alert (msg); } } else stringValue = NULL; if (rhs.intArrayValue) { intArrayValue = new vector <int>; * intArrayValue = * rhs.intArrayValue; } else intArrayValue = NULL; if (rhs.doubleArrayValue) { doubleArrayValue = new vector <double>; * doubleArrayValue = * rhs.doubleArrayValue; } else doubleArrayValue = NULL; if (rhs.stringArrayValue) { stringArrayValue = new vector <string>; * stringArrayValue = * rhs.stringArrayValue; } else stringArrayValue = NULL; if (rhs.compressedData && rhs.compressedDataLength) { unsigned long num = rhs.uncompressedStringLengths.size (); if (vectorFlag && num) { // if a vector of strings, copy the uncompressed string lengths uncompressedStringLengths.resize (num); for (unsigned long i = 0; i < num; i++) uncompressedStringLengths [i] = rhs.uncompressedStringLengths [i]; } // copy the size of the compressed data compressedDataLength = rhs.compressedDataLength; // allocate and copy the compressed data compressedData = (unsigned char *) malloc (rhs.compressedDataLength); if ( ! compressedData) alert ("DesValue::DesValue (const DesValue &) - unable to malloc " + asString (rhs.compressedDataLength) + " bytes"); memcpy_s (compressedData, rhs.compressedDataLength, rhs.compressedData, rhs.compressedDataLength); } else { compressedData = NULL; compressedDataLength = 0; uncompressedStringLengths.resize (0); } if (rhs.uncompressedString) { uncompressedString = new std::string; * uncompressedString = * rhs.uncompressedString; } else uncompressedString = NULL; isTouched = rhs.isTouched; isSetFlag = rhs.isSetFlag; unitsValue = rhs.unitsValue; unitsValue2 = rhs.unitsValue2; errorMessage = rhs.errorMessage; unitsArgs = rhs.unitsArgs; } Lynn |
"Tobias Müller" <troplin@bluewin.ch>: Dec 30 05:52PM > I am not against using threads. I was arguing against generic claim of > Leigh that multithreading is superior solution than multiprocessing. > Neither is generally superior. Each has usages. That must be a typo. Certainly you meant SAusages. > [...] Tobi |
Jack Chuge <zhuge.jack@gmail.com>: Dec 30 11:07PM +0800 Richard 於 2014-11-12 5:12 寫道: > ahead of time and have them work a solution on their own time at their > own pace. > Even better than that is to pair program with them for a day. Great points -- Jack |
Jack Chuge <zhuge.jack@gmail.com>: Dec 30 10:55PM +0800 BV BV 於 2014-11-14 22:05 寫道: > Woman's dress in Islam > According to religion of Islam woman should only display her face and palms of hands in front of foreigner men (indoor and outdoor) and more than that is prohibited. > Allah Almighty tells prophet Mohamed peace be upon him to order women to do the following: (And tell the believing women to lower their gaze (from looking at forbidden things), and protect their private parts (from illegal sexual acts) and not to show off their adornment except only that which is apparent (like both eyes for necessity to see the way, or outer palms of hands or one eye or dress like veil, gloves, head-cover, apron, etc.), and to draw their veils all over Juyûbihinna (i.e. their bodies, faces, necks and bosoms) and not to reveal their adornment except to their husbands, or their fathers, or their husband's fathers, or their sons, or their husband's sons, or their brothers or their brother's sons, or their sister's sons, or their (Muslim) women (i.e. their sisters in Islâm), or the (female) slaves whom their right hands possess, or old male servants who lack vigour, or small children who have no sense of feminine sex. And let them not stamp their feet so as to reve al what they hide of their adornment. And all of you beg Allâh to forgive you all, O believers, that you may be successful.){ Sûrat An-Nûr - The Light -verse31}. > * http://www.boston.com/news/nation/washington/articles/2008/07/11/skin_cancer_on_rise_in_young_women/ > * http://www.medicalnewstoday.com/articles/44764.php > Thank you It's a polite way to lower gaze from both men and women -- Jack |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment