Mercurial > hg > truffle
comparison src/share/tools/launcher/jli_util.c @ 1985:cb2d0a362639
6981484: Update development launcher
Summary: Add new development launcher called hotspot(.exe)
Reviewed-by: coleenp
author | sla |
---|---|
date | Thu, 02 Dec 2010 05:45:54 -0800 |
parents | |
children | aa6e219afbf1 |
comparison
equal
deleted
inserted
replaced
1984:2968675b413e | 1985:cb2d0a362639 |
---|---|
1 /* | |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #include <stdio.h> | |
26 #include <string.h> | |
27 #include "jli_util.h" | |
28 | |
29 #ifdef GAMMA | |
30 #ifdef _WINDOWS | |
31 #define strdup _strdup | |
32 #endif | |
33 #endif | |
34 | |
35 /* | |
36 * Returns a pointer to a block of at least 'size' bytes of memory. | |
37 * Prints error message and exits if the memory could not be allocated. | |
38 */ | |
39 void * | |
40 JLI_MemAlloc(size_t size) | |
41 { | |
42 void *p = malloc(size); | |
43 if (p == 0) { | |
44 perror("malloc"); | |
45 exit(1); | |
46 } | |
47 return p; | |
48 } | |
49 | |
50 /* | |
51 * Equivalent to realloc(size). | |
52 * Prints error message and exits if the memory could not be reallocated. | |
53 */ | |
54 void * | |
55 JLI_MemRealloc(void *ptr, size_t size) | |
56 { | |
57 void *p = realloc(ptr, size); | |
58 if (p == 0) { | |
59 perror("realloc"); | |
60 exit(1); | |
61 } | |
62 return p; | |
63 } | |
64 | |
65 /* | |
66 * Wrapper over strdup(3C) which prints an error message and exits if memory | |
67 * could not be allocated. | |
68 */ | |
69 char * | |
70 JLI_StringDup(const char *s1) | |
71 { | |
72 char *s = strdup(s1); | |
73 if (s == NULL) { | |
74 perror("strdup"); | |
75 exit(1); | |
76 } | |
77 return s; | |
78 } | |
79 | |
80 /* | |
81 * Very equivalent to free(ptr). | |
82 * Here to maintain pairing with the above routines. | |
83 */ | |
84 void | |
85 JLI_MemFree(void *ptr) | |
86 { | |
87 free(ptr); | |
88 } |