< prev index next >

src/java.base/share/native/libjli/jli_util.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,40 **** */ #include <stdio.h> #include <string.h> #include <stdarg.h> #include "jli_util.h" /* * Returns a pointer to a block of at least 'size' bytes of memory. * Prints error message and exits if the memory could not be allocated. */ ! void * JLI_MemAlloc(size_t size) { void *p = malloc(size); if (p == 0) { perror("malloc"); --- 24,41 ---- */ #include <stdio.h> #include <string.h> #include <stdarg.h> + #include "jni.h" #include "jli_util.h" /* * Returns a pointer to a block of at least 'size' bytes of memory. * Prints error message and exits if the memory could not be allocated. */ ! JNIEXPORT void * JNICALL JLI_MemAlloc(size_t size) { void *p = malloc(size); if (p == 0) { perror("malloc");
*** 60,70 **** /* * Wrapper over strdup(3C) which prints an error message and exits if memory * could not be allocated. */ ! char * JLI_StringDup(const char *s1) { char *s = strdup(s1); if (s == NULL) { perror("strdup"); --- 61,71 ---- /* * Wrapper over strdup(3C) which prints an error message and exits if memory * could not be allocated. */ ! JNIEXPORT char * JNICALL JLI_StringDup(const char *s1) { char *s = strdup(s1); if (s == NULL) { perror("strdup");
*** 75,85 **** /* * Very equivalent to free(ptr). * Here to maintain pairing with the above routines. */ ! void JLI_MemFree(void *ptr) { free(ptr); } --- 76,86 ---- /* * Very equivalent to free(ptr). * Here to maintain pairing with the above routines. */ ! JNIEXPORT void JNICALL JLI_MemFree(void *ptr) { free(ptr); }
*** 97,107 **** vprintf(fmt,vl); va_end(vl); fflush(stdout); } ! void JLI_SetTraceLauncher() { if (getenv(JLDEBUG_ENV_ENTRY) != 0) { _launcher_debug = JNI_TRUE; JLI_TraceLauncher("----%s----\n", JLDEBUG_ENV_ENTRY); --- 98,108 ---- vprintf(fmt,vl); va_end(vl); fflush(stdout); } ! JNIEXPORT void JNICALL JLI_SetTraceLauncher() { if (getenv(JLDEBUG_ENV_ENTRY) != 0) { _launcher_debug = JNI_TRUE; JLI_TraceLauncher("----%s----\n", JLDEBUG_ENV_ENTRY);
*** 118,128 **** JLI_StrCCmp(const char *s1, const char* s2) { return JLI_StrNCmp(s1, s2, JLI_StrLen(s2)); } ! JLI_List JLI_List_new(size_t capacity) { JLI_List l = (JLI_List) JLI_MemAlloc(sizeof(struct JLI_List_)); l->capacity = capacity; l->elements = (char **) JLI_MemAlloc(capacity * sizeof(l->elements[0])); --- 119,129 ---- JLI_StrCCmp(const char *s1, const char* s2) { return JLI_StrNCmp(s1, s2, JLI_StrLen(s2)); } ! JNIEXPORT JLI_List JNICALL JLI_List_new(size_t capacity) { JLI_List l = (JLI_List) JLI_MemAlloc(sizeof(struct JLI_List_)); l->capacity = capacity; l->elements = (char **) JLI_MemAlloc(capacity * sizeof(l->elements[0]));
*** 153,163 **** sl->elements = JLI_MemRealloc(sl->elements, sl->capacity * sizeof(sl->elements[0])); } } ! void JLI_List_add(JLI_List sl, char *str) { JLI_List_ensureCapacity(sl, sl->size+1); sl->elements[sl->size++] = str; } --- 154,164 ---- sl->elements = JLI_MemRealloc(sl->elements, sl->capacity * sizeof(sl->elements[0])); } } ! JNIEXPORT void JNICALL JLI_List_add(JLI_List sl, char *str) { JLI_List_ensureCapacity(sl, sl->size+1); sl->elements[sl->size++] = str; }
< prev index next >