src/hotspot/share/services/diagnosticArgument.cpp
changeset 53882 ca682d9d8db5
parent 50600 8e17fffa0a4b
child 53908 45a23c64d0f6
equal deleted inserted replaced
53881:db24a4cb8139 53882:ca682d9d8db5
     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) {