test/hotspot/gtest/logging/logTestUtils.inline.hpp
changeset 51070 2f4c3cac8556
parent 49016 ea85eed8b012
child 53845 1807da9ad196
equal deleted inserted replaced
51069:d5d5f6658b12 51070:2f4c3cac8556
     1 /*
     1 /*
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2018, 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.
    93 static inline char* read_line(FILE* fp) {
    93 static inline char* read_line(FILE* fp) {
    94   assert(fp != NULL, "invalid fp");
    94   assert(fp != NULL, "invalid fp");
    95   int buflen = 512;
    95   int buflen = 512;
    96   char* buf = NEW_RESOURCE_ARRAY(char, buflen);
    96   char* buf = NEW_RESOURCE_ARRAY(char, buflen);
    97   long pos = ftell(fp);
    97   long pos = ftell(fp);
       
    98   if (pos < 0) return NULL;
    98 
    99 
    99   char* ret = fgets(buf, buflen, fp);
   100   char* ret = fgets(buf, buflen, fp);
   100   while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
   101   while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) {
   101     // retry with a larger buffer
   102     // retry with a larger buffer
   102     buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);
   103     buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2);