equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
177 template <> void DCmdArgument<char*>::parse_value(const char* str, |
177 template <> void DCmdArgument<char*>::parse_value(const char* str, |
178 size_t len, TRAPS) { |
178 size_t len, TRAPS) { |
179 if (str == NULL) { |
179 if (str == NULL) { |
180 _value = NULL; |
180 _value = NULL; |
181 } else { |
181 } else { |
182 _value = NEW_C_HEAP_ARRAY(char, len+1, mtInternal); |
182 _value = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal); |
183 strncpy(_value, str, len); |
183 int n = snprintf(_value, len + 1, "%.*s", (int)len, str); |
184 _value[len] = 0; |
184 assert((size_t)n <= len, "Unexpected number of characters in string"); |
185 } |
185 } |
186 } |
186 } |
187 |
187 |
188 template <> void DCmdArgument<char*>::init_value(TRAPS) { |
188 template <> void DCmdArgument<char*>::init_value(TRAPS) { |
189 if (has_default() && _default_string != NULL) { |
189 if (has_default() && _default_string != NULL) { |