hotspot/src/share/tools/launcher/jli_util.c
author mullan
Wed, 26 Dec 2012 10:08:36 -0500
changeset 14924 43383e2d85a6
parent 7452 b3fa838286de
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7452
b3fa838286de 7006354: Updates to Visual Studio project creation and development launcher
sla
parents: 7410
diff changeset
     1
7410
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     2
/*
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     3
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     5
 *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     8
 * published by the Free Software Foundation.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
     9
 *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    14
 * accompanied this code).
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    15
 *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    19
 *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    22
 * questions.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    23
 *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    24
 */
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    25
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    26
#include <stdio.h>
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    27
#include <string.h>
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    28
#include "jli_util.h"
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    29
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    30
#ifdef GAMMA
7452
b3fa838286de 7006354: Updates to Visual Studio project creation and development launcher
sla
parents: 7410
diff changeset
    31
#ifdef TARGET_OS_FAMILY_windows
7410
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    32
#define strdup _strdup
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    33
#endif
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    34
#endif
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    35
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    36
/*
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    37
 * Returns a pointer to a block of at least 'size' bytes of memory.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    38
 * Prints error message and exits if the memory could not be allocated.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    39
 */
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    40
void *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    41
JLI_MemAlloc(size_t size)
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    42
{
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    43
    void *p = malloc(size);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    44
    if (p == 0) {
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    45
        perror("malloc");
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    46
        exit(1);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    47
    }
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    48
    return p;
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    49
}
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    50
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    51
/*
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    52
 * Equivalent to realloc(size).
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    53
 * Prints error message and exits if the memory could not be reallocated.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    54
 */
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    55
void *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    56
JLI_MemRealloc(void *ptr, size_t size)
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    57
{
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    58
    void *p = realloc(ptr, size);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    59
    if (p == 0) {
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    60
        perror("realloc");
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    61
        exit(1);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    62
    }
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    63
    return p;
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    64
}
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    65
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    66
/*
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    67
 * Wrapper over strdup(3C) which prints an error message and exits if memory
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    68
 * could not be allocated.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    69
 */
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    70
char *
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    71
JLI_StringDup(const char *s1)
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    72
{
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    73
    char *s = strdup(s1);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    74
    if (s == NULL) {
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    75
        perror("strdup");
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    76
        exit(1);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    77
    }
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    78
    return s;
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    79
}
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    80
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    81
/*
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    82
 * Very equivalent to free(ptr).
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    83
 * Here to maintain pairing with the above routines.
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    84
 */
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    85
void
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    86
JLI_MemFree(void *ptr)
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    87
{
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    88
    free(ptr);
f5b282e7a7a6 6981484: Update development launcher
sla
parents:
diff changeset
    89
}