[libc-commits] [PATCH] D74021: Created uChar implementation for libc

Marcus Johnson via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Feb 8 04:49:01 PST 2020


MarcusJohnson91 updated this revision to Diff 243361.
MarcusJohnson91 added a comment.

Removed all of the new calls, starting work on the latest comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74021/new/

https://reviews.llvm.org/D74021

Files:
  libc/src/uchar/c16rtomb.cpp
  libc/src/uchar/c32rtomb.cpp
  libc/src/uchar/mbrtoc16.cpp
  libc/src/uchar/mbrtoc32.cpp


Index: libc/src/uchar/mbrtoc32.cpp
===================================================================
--- libc/src/uchar/mbrtoc32.cpp
+++ libc/src/uchar/mbrtoc32.cpp
@@ -17,7 +17,6 @@
                                       const char *restrict s, size_t n,
                                       mbstate_t *restrict ps) {
   size_t StringSize = 1;
-  pc32 = new char32_t(StringSize);
 
   switch (n) {
   case 1:
Index: libc/src/uchar/mbrtoc16.cpp
===================================================================
--- libc/src/uchar/mbrtoc16.cpp
+++ libc/src/uchar/mbrtoc16.cpp
@@ -42,11 +42,9 @@
 
   if (Decoded <= 0xFFFF) {
     StringSize = 1;
-    pc16 = new char16_t(StringSize);
     pc16[0] = Decoded & 0xFFFF;
   } else if (Decoded <= 0x10FFFF) {
     StringSize = 2;
-    pc16 = new char16_t(StringSize);
     pc16[0] = 0xD800 + ((Decoded & 0xFFC00) >> 10);
     pc16[1] = 0xDC00 + (Decoded & 0x3FF);
   }
Index: libc/src/uchar/c32rtomb.cpp
===================================================================
--- libc/src/uchar/c32rtomb.cpp
+++ libc/src/uchar/c32rtomb.cpp
@@ -18,22 +18,18 @@
   size_t StringSize = 0;
   if (c32 <= 0x7F) {
     StringSize = 1;
-    s = new char(StringSize);
     s[0] = c32 & 0x7F;
   } else if (c32 <= 0x7FF) {
     StringSize = 2;
-    s = new char(StringSize);
     s[0] = 0xC0 | (c32 & ((0x1F << 6) >> 6));
     s[1] = 0x80 | (c32 & 0x3F);
   } else if (c32 <= 0xFFFF) {
     StringSize = 3;
-    s = new char(StringSize);
     s[0] = 0xE0 | (c32 & ((0x0F << 12) >> 12));
     s[1] = 0x80 | (c32 & ((0x3F << 6) >> 6));
     s[2] = 0x80 | (c32 & 0x3F);
   } else if (c32 <= 0x10FFFF) {
     StringSize = 4;
-    s = new char(StringSize);
     s[0] = 0xF0 | (c32 & 0x1C0000) >> 18;
     s[1] = 0x80 | (c32 & 0x3F000) >> 12;
     s[2] = 0x80 | (c32 & 0xFC0) >> 6;
Index: libc/src/uchar/c16rtomb.cpp
===================================================================
--- libc/src/uchar/c16rtomb.cpp
+++ libc/src/uchar/c16rtomb.cpp
@@ -22,16 +22,13 @@
 
   if (c16 <= 0x7F) {
     StringSize = 1;
-    s = new char(StringSize);
     s[0] = c16 & 0x7F;
   } else if (c16 <= 0x7FF) {
     StringSize = 2;
-    s = new char(StringSize);
     s[0] = 0xC0 | (c16 & ((0x1F << 6) >> 6));
     s[1] = 0x80 | (c16 & 0x3F);
   } else if (c16 <= 0xFFFF) {
     StringSize = 3;
-    s = new char(StringSize);
     s[0] = 0xE0 | (c16 & ((0x0F << 12) >> 12));
     s[1] = 0x80 | (c16 & ((0x3F << 6) >> 6));
     s[2] = 0x80 | (c16 & 0x3F);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74021.243361.patch
Type: text/x-patch
Size: 2474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200208/d8a8b513/attachment.bin>


More information about the libc-commits mailing list