Keep a reference to new'ed TextEncoding singletons.
Keep a reference to new'ed TextEncoding singletons.

The original code expands to:

  WTF::lockAtomicallyInitializedStaticMutex();
  static TextEncoding globalUTF7Encoding = *new TextEncoding("UTF-7");
  WTF::unlockAtomicallyInitializedStaticMutex();

which makes a copy of the allocated TextEncoding and leaks the original. Using AtomicallyInitializedStatic(const TextEncoding&, ...) stores the pointer value in an immortal reference instead, which lets valgrind know that it's still reachable. Storing a reference instead of a value eliminates the static destructor.

BUG=447728

Review URL: https://codereview.chromium.org/841393002

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@188178 bbb929c8-8fbe-4397-9dbb-9b2b20218538

PeterWangIntel/blink-crosswalk,kurli/blink-crosswalk,Pluto-tv/blink-crosswalk,kurli/blink-crosswalk,PeterWangIntel/blink-crosswalk,Pluto-tv/blink-crosswalk,smishenk/blink-crosswalk,Bysmyyr/blink-crosswalk,PeterWangIntel/blink-crosswalk,Pluto-tv/blink-crosswalk,PeterWangIntel/blink-crosswalk,XiaosongWei/blink-crosswalk,XiaosongWei/blink-crosswalk,Bysmyyr/blink-crosswalk,PeterWangIntel/blink-crosswalk,Pluto-tv/blink-crosswalk,kurli/blink-crosswalk,Bysmyyr/blink-crosswalk,smishenk/blink-crosswalk,XiaosongWei/blink-crosswalk,smishenk/blink-crosswalk,smishenk/blink-crosswalk,Bysmyyr/blink-crosswalk,XiaosongWei/blink-crosswalk,XiaosongWei/blink-crosswalk,smishenk/blink-crosswalk,Pluto-tv/blink-crosswalk,Bysmyyr/blink-crosswalk,kurli/blink-crosswalk,PeterWangIntel/blink-crosswalk,Bysmyyr/blink-crosswalk,XiaosongWei/blink-crosswalk,Pluto-tv/blink-crosswalk,smishenk/blink-crosswalk,Bysmyyr/blink-crosswalk,Pluto-tv/blink-crosswalk,kurli/blink-crosswalk,XiaosongWei/blink-crosswalk,XiaosongWei/blink-crosswalk,PeterWangIntel/blink-crosswalk,PeterWangIntel/blink-crosswalk,Bysmyyr/blink-crosswalk,kurli/blink-crosswalk,Pluto-tv/blink-crosswalk,XiaosongWei/blink-crosswalk,Bysmyyr/blink-crosswalk,smishenk/blink-crosswalk,kurli/blink-crosswalk,smishenk/blink-crosswalk,Pluto-tv/blink-crosswalk,XiaosongWei/blink-crosswalk,smishenk/blink-crosswalk,kurli/blink-crosswalk,kurli/blink-crosswalk,smishenk/blink-crosswalk,PeterWangIntel/blink-crosswalk,PeterWangIntel/blink-crosswalk,Bysmyyr/blink-crosswalk,Pluto-tv/blink-crosswalk,kurli/blink-crosswalk