几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】memory management - odrxallocodrxrealloc (http://www.dimcax.com/hust/showthread.php?t=17184)

yang686526 2009-05-06 05:40 PM

【转帖】memory management - odrxallocodrxrealloc
 
memory management - odrxalloc/odrxrealloc
memory management - odrxalloc/odrxrealloc
i have provided my own implementation of the the odalloc.h functions: odrxalloc and odrxrealloc. if my custom implementation cannot allocate memory for some reasons, should i be throwing an oderror(eoutofmemory) exception?
however these are defined in extern "c" block in the header file odalloc.h.
this means i am not supposed to throw from them(as expected there's a warning by vc compiler if i do so). should i just return null if my odrxalloc and odrxrealloc fail??
tia
alex.
odrxalloc and odrxrealloc functions are analgous to ::malloc/::free pair, and should not throw exceptions. (but, your overloaded "new" operator should throw exception if allocation fails)
vladimir


所有的时间均为北京时间。 现在的时间是 10:49 AM.