Chromium Code Reviews| Index: src/IceCfg.h |
| diff --git a/src/IceCfg.h b/src/IceCfg.h |
| index 71f0a0d54fa17ab97ab7a49296435f83555baddc..6916924d27e7dcf82c2da39af9925cefba92041e 100644 |
| --- a/src/IceCfg.h |
| +++ b/src/IceCfg.h |
| @@ -30,17 +30,16 @@ class Cfg { |
| public: |
| ~Cfg(); |
| - // TODO(stichnot): Change this to return unique_ptr<Cfg>, and plumb |
| - // it through the callers, to make ownership and lifetime and |
| - // destruction requirements more explicit. |
| - static Cfg *create(GlobalContext *Ctx) { |
| + static std::unique_ptr<Cfg> create(GlobalContext *Ctx) { |
| Cfg *Func = new Cfg(Ctx); |
|
JF
2015/02/02 20:59:19
It's slightly better to make this a unique_ptr too
Jim Stichnoth
2015/02/03 00:48:51
Done.
|
| ICE_TLS_SET_FIELD(CurrentCfg, Func); |
| - return Func; |
| + return std::unique_ptr<Cfg>(Func); |
| } |
| // Gets a pointer to the current thread's Cfg. |
| static const Cfg *getCurrentCfg() { return ICE_TLS_GET_FIELD(CurrentCfg); } |
| - void updateTLS() const { ICE_TLS_SET_FIELD(CurrentCfg, this); } |
| + static void updateTLS(const Cfg *Func) { |
| + ICE_TLS_SET_FIELD(CurrentCfg, Func); |
| + } |
| // Gets a pointer to the current thread's Cfg's allocator. |
| static ArenaAllocator<> *getCurrentCfgAllocator() { |
| assert(ICE_TLS_GET_FIELD(CurrentCfg)); |