From ee563973094a8235631d5208bd672f8cbbe15fdc Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: 2011年12月18日 00:02:19 +0100 Subject: Eliminate C++ exceptions from graphical system implementation The rationale is that everything is simpler without C++ exceptions. No exceptions are raised in the C++ code and errors are handler in the tradition C fashion. lua_error is not directly called from C++ functions that may allocate a non POD object on the stack. If the C++ "new" operator raise an exception the program will abort. The idea is that handle such an improbable occurrence greatly complicates the code. Where big chunks of memory are allocated the nothrow variant of "new" is used, the returned pointer is verified and an error is raised if the allocation failed. In the Windows code the bitmap allocation for image may raise an unhandled exception in there is not enough memory. The memory allocation is done inside the AGG library so it difficult to change its behavior. --- agg-plot/lua-draw.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'agg-plot/lua-draw.cpp') diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp index d533e745..ea1e8f61 100644 --- a/agg-plot/lua-draw.cpp +++ b/agg-plot/lua-draw.cpp @@ -182,16 +182,7 @@ agg_path_cmd (lua_State *L) } pthread_mutex_lock (agg_mutex); - try - { - path_cmd (p, id, s); - } - catch (std::bad_alloc&) - { - pthread_mutex_unlock (agg_mutex); - luaL_error (L, "out of memory"); - return 0; - } + path_cmd (p, id, s); pthread_mutex_unlock (agg_mutex); return 0; } -- cgit v1.2.3

AltStyle によって変換されたページ (->オリジナル) /