| OLD | NEW |
| 1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 buf[0] = '\000'; | 644 buf[0] = '\000'; |
| 645 return NULL; | 645 return NULL; |
| 646 } | 646 } |
| 647 | 647 |
| 648 char *start = buf; | 648 char *start = buf; |
| 649 | 649 |
| 650 uintptr_t j = i; | 650 uintptr_t j = i; |
| 651 | 651 |
| 652 // Handle negative numbers (only for base 10). | 652 // Handle negative numbers (only for base 10). |
| 653 if (i < 0 && base == 10) { | 653 if (i < 0 && base == 10) { |
| 654 j = -i; | 654 // This does "j = -i" while avoiding integer overflow. |
| 655 j = static_cast<uintptr_t>(-(i + 1)) + 1; |
| 655 | 656 |
| 656 // Make sure we can write the '-' character. | 657 // Make sure we can write the '-' character. |
| 657 if (++n > sz) { | 658 if (++n > sz) { |
| 658 buf[0] = '\000'; | 659 buf[0] = '\000'; |
| 659 return NULL; | 660 return NULL; |
| 660 } | 661 } |
| 661 *start++ = '-'; | 662 *start++ = '-'; |
| 662 } | 663 } |
| 663 | 664 |
| 664 // Loop until we have converted the entire number. Output at least one | 665 // Loop until we have converted the entire number. Output at least one |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 | 840 |
| 840 // TODO: Support other environments. | 841 // TODO: Support other environments. |
| 841 bool Symbolize(void *pc, char *out, int out_size) { | 842 bool Symbolize(void *pc, char *out, int out_size) { |
| 842 assert(0); | 843 assert(0); |
| 843 return false; | 844 return false; |
| 844 } | 845 } |
| 845 | 846 |
| 846 _END_GOOGLE_NAMESPACE_ | 847 _END_GOOGLE_NAMESPACE_ |
| 847 | 848 |
| 848 #endif | 849 #endif |
| OLD | NEW |