You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/15 23:21:54 UTC
svn commit: r815495 - in /commons/sandbox/runtime/trunk/src/main/native:
include/ include/arch/unix/ include/arch/windows/ os/unix/ os/win32/ shared/
Author: mturk
Date: Tue Sep 15 21:21:51 2009
New Revision: 815495
URL: http://svn.apache.org/viewvc?rev=815495&view=rev
Log:
Use some handy alloc macros that clear the code readibility
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/acr_memory.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
commons/sandbox/runtime/trunk/src/main/native/shared/string.c
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_memory.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_memory.h?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_memory.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_memory.h Tue Sep 15 21:21:51 2009
@@ -31,6 +31,9 @@
*
*/
+#define ACR_MALLOC(T, N) ((T *)ACR_Malloc(_E, THROW_FMARK, sizeof(T) * (N)))
+#define ACR_CALLOC(T, N) ((T *)ACR_Calloc(_E, THROW_FMARK, sizeof(T) * (N)))
+
/** Opaque Small Block Heap structure */
typedef struct acr_sbh_t acr_sbh_t;
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/unix/acr_arch.h Tue Sep 15 21:21:51 2009
@@ -131,6 +131,39 @@
}
}
+#define s_malloc(T, N) ((T *)x_malloc(sizeof(T) * (N)))
+#define s_calloc(T, N) ((T *)x_calloc(sizeof(T) * (N)))
+
+static ACR_INLINE char *x_strdup(const char *s)
+{
+ char *d = NULL;
+ if (s) {
+ size_t size = strlen(s);
+ d = (char *)x_malloc(size + 2);
+ if (d) {
+ memcpy(d, s, size);
+ d[size] = '\0';
+ d[size+1] = '\0';
+ }
+ }
+ return d;
+}
+
+static ACR_INLINE wchar_t *x_wcsdup(const wchar_t *s)
+{
+ wchar_t *d = NULL;
+ if (s) {
+ size_t size = wcslen(s);
+ d = (wchar_t *)x_malloc((size + 2) * sizeof(wchar_t));
+ if (d) {
+ memcpy(d, s, size * sizeof(wchar_t));
+ d[size] = L'\0';
+ d[size+1] = L'\0';
+ }
+ }
+ return d;
+}
+
/* restartable read() */
static ACR_INLINE ssize_t r_read(int fd, void *buf, size_t count)
{
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Tue Sep 15 21:21:51 2009
@@ -347,6 +347,9 @@
}
}
+#define s_malloc(T, N) ((T *)x_malloc(sizeof(T) * (N)))
+#define s_calloc(T, N) ((T *)x_calloc(sizeof(T) * (N)))
+
static ACR_INLINE char *x_strdup(const char *s)
{
char *d = NULL;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c Tue Sep 15 21:21:51 2009
@@ -110,7 +110,7 @@
return ACR_EINVAL;
__bmp_size = __ioh_size >> 3;
acr_ioh_mask = __ioh_size - 1;
- acr_ioh_tab = (acr_ioh *)x_calloc(sizeof(acr_ioh) * __ioh_size);
+ acr_ioh_tab = s_calloc(acr_ioh, __ioh_size);
if (acr_ioh_tab) {
acr_ioh_tab[acr_ioh_mask] = nul_ioh_tab;
}
@@ -148,7 +148,7 @@
return ACR_ERANGE;
}
nb = ns >> 3;
- io = (acr_ioh *)x_calloc(sizeof(acr_ioh) * ns);
+ io = s_calloc(acr_ioh, ns);
if (io) {
memcpy(io, acr_ioh_tab, sizeof(acr_ioh) * acr_ioh_mask);
x_free(acr_ioh_tab);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Tue Sep 15 21:21:51 2009
@@ -117,7 +117,7 @@
tlsd = (acr_thread_local_t *)pthread_getspecific(acr_thread_key);
if (tlsd == NULL) {
- tlsd = x_calloc(sizeof(acr_thread_local_t));
+ tlsd = s_calloc(acr_thread_local_t, 1);
if (tlsd == NULL) {
memset(&_null_tlsd, 0, sizeof(acr_thread_local_t));
return &_null_tlsd;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/mmap.c Tue Sep 15 21:21:51 2009
@@ -174,7 +174,7 @@
ACR_THROW_EX_IF_ERR(ACR_EX_EINVAL, ACR_EBADF);
return -1;
}
- map = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_mmap_t));
+ map = ACR_CALLOC(acr_mmap_t, 1);
if (!map)
return -1;
@@ -205,7 +205,7 @@
ACR_THROW_IO_ERRNO();
return -1;
}
- map = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_mmap_t));
+ map = ACR_CALLOC(acr_mmap_t, 1);
if (!map) {
return -1;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/mutex.c Tue Sep 15 21:21:51 2009
@@ -184,7 +184,7 @@
close(fd);
flags |= IPC_EXCL;
}
- m = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_pmutex_t));
+ m = ACR_CALLOC(acr_pmutex_t, 1);
if (!m)
return -1;
if (fname) {
@@ -257,7 +257,7 @@
return -1;
}
close(file);
- m = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_pmutex_t));
+ m = ACR_CALLOC(acr_pmutex_t, 1);
if (!m)
return -1;
@@ -464,7 +464,7 @@
acr_pmutex_t *m;
char *p;
- m = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_pmutex_t));
+ m = ACR_CALLOC(acr_pmutex_t, 1);
if (!m)
return -1;
if (!name)
@@ -527,7 +527,7 @@
rc = ACR_EINVAL;
goto finally;
}
- m = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_pmutex_t));
+ m = ACR_CALLOC(acr_pmutex_t, 1);
if (!m)
return -1;
if (*name != '/')
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/sema.c Tue Sep 15 21:21:51 2009
@@ -85,7 +85,7 @@
acr_semaphore_t *s;
char *p;
- s = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_semaphore_t));
+ s = ACR_CALLOC(acr_semaphore_t, 1);
if (!s)
return -1;
if (!name)
@@ -148,7 +148,7 @@
rc = ACR_EINVAL;
goto finally;
}
- s = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_semaphore_t));
+ s = ACR_CALLOC(acr_semaphore_t, 1);
if (!s)
return -1;
if (*name != '/')
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c Tue Sep 15 21:21:51 2009
@@ -210,7 +210,7 @@
ACR_THROW_EX_IF_ERR(ACR_EX_EINVAL, ACR_EINVAL);
return -1;
}
- shm = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_shm_t));
+ shm = ACR_CALLOC(acr_shm_t, 1);
if (!shm)
return -1;
/* Check if they want anonymous or name-based shared memory */
@@ -327,7 +327,7 @@
ACR_THROW_IO_IF_ERR(ACR_EINVAL);
return -1;
}
- shm = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_shm_t));
+ shm = ACR_CALLOC(acr_shm_t, 1);
if (!shm)
return -1;
shm->filename = ACR_StrdupA(_E, THROW_FMARK, filename);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c Tue Sep 15 21:21:51 2009
@@ -114,7 +114,7 @@
if (rc) {
goto finally;
}
- fp = ACR_Calloc(_E, THROW_NMARK, sizeof(acr_file_t));
+ fp = ACR_CALLOC(acr_file_t, 1);
if (!fp) {
goto cleanup;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/env.c Tue Sep 15 21:21:51 2009
@@ -230,7 +230,7 @@
DWORD siz;
siz = ExpandEnvironmentStringsW(env, NULL, 0);
if (siz) {
- buf = x_malloc(siz * sizeof(wchar_t));
+ buf = s_malloc(wchar_t, siz);
if (buf == NULL)
return NULL;
siz = ExpandEnvironmentStringsW(env, buf, siz);
@@ -256,8 +256,8 @@
errno = EINVAL;
return -1;
}
- elen = (wcslen(var) + wcslen(val) + 2) * sizeof(wchar_t);
- estr = (wchar_t *)x_malloc(elen);
+ elen = wcslen(var) + wcslen(val) + 2;
+ estr = s_malloc(wchar_t, elen);
if (!estr) {
/* not much we can do if no memory */
ACR_SET_OS_ERROR(ACR_ENOMEM);
@@ -288,8 +288,8 @@
}
if (_wgetenv(var) == NULL)
return 0; /* no work */
- elen = (wcslen(var) + 2) * sizeof(wchar_t);
- estr = (wchar_t *)x_malloc(elen);
+ elen = (wcslen(var) + 2);
+ estr = s_malloc(wchar_t, elen);
if (!estr) {
/* not much we can do if no memory */
ACR_SET_OS_ERROR(ACR_ENOMEM);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c Tue Sep 15 21:21:51 2009
@@ -85,7 +85,7 @@
return ACR_EINVAL;
__bmp_size = __ioh_size >> 3;
acr_ioh_mask = __ioh_size - 1;
- acr_ioh_tab = (acr_ioh *)x_calloc(sizeof(acr_ioh) * __ioh_size);
+ acr_ioh_tab = s_calloc(acr_ioh, __ioh_size);
if (acr_ioh_tab) {
acr_ioh_tab[acr_ioh_mask] = nul_ioh_tab;
}
@@ -135,7 +135,7 @@
return ACR_ERANGE;
}
nb = ns >> 3;
- io = (acr_ioh *)x_calloc(sizeof(acr_ioh) * ns);
+ io = s_calloc(acr_ioh, ns);
if (io) {
memcpy(io, acr_ioh_tab, sizeof(acr_ioh) * acr_ioh_mask);
x_free(acr_ioh_tab);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/mmap.c Tue Sep 15 21:21:51 2009
@@ -156,7 +156,7 @@
ACR_THROW_EX_IF_ERR(ACR_EX_EINVAL, ACR_EBADF);
return -1;
}
- map = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_mmap_t));
+ map = ACR_CALLOC(acr_mmap_t, 1);
if (!map)
return -1;
@@ -200,7 +200,7 @@
DWORD prot = 0;
acr_mmap_t *map;
- map = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_mmap_t));
+ map = ACR_CALLOC(acr_mmap_t, 1);
if (!map)
return -1;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Tue Sep 15 21:21:51 2009
@@ -146,7 +146,7 @@
sizehi = 0;
#endif
- shm = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_shm_t));
+ shm = ACR_CALLOC(acr_shm_t, 1);
if (!shm)
return -1;
/* Check if they want anonymous or name-based shared memory */
@@ -270,7 +270,7 @@
rc = ACR_EINVAL;
goto finally;
}
- shm = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_shm_t));
+ shm = ACR_CALLOC(acr_shm_t, 1);
if (!shm)
return -1;
if (_wcsnicmp(filename, L"shared::", 8) == 0) {
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c Tue Sep 15 21:21:51 2009
@@ -469,7 +469,7 @@
cs = ERROR_SUCCESS;
}
if (cs == ERROR_SUCCESS) {
- pd = x_calloc(sizeof(sig_pipe_data_t));
+ pd = s_calloc(sig_pipe_data_t, 1);
if (pd == NULL) {
/* ###: Fatal error ?
*/
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c Tue Sep 15 21:21:51 2009
@@ -281,7 +281,7 @@
ACR_THROW_IO_ERRNO();
return -1;
}
- fp = ACR_Calloc(_E, THROW_NMARK, sizeof(acr_file_t));
+ fp = ACR_CALLOC(acr_file_t, 1);
if (!fp) {
goto cleanup;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Tue Sep 15 21:21:51 2009
@@ -231,7 +231,7 @@
ACR_SET_OS_ERROR(ACR_EILSEQ);
return NULL;
}
- res = x_malloc(len * sizeof(wchar_t));
+ res = s_malloc(wchar_t, len);
if (!res)
return NULL;
if ((rc = utf8_to_unicode_path(res, len, str))) {
@@ -254,7 +254,7 @@
ACR_SET_OS_ERROR(ACR_EILSEQ);
return NULL;
}
- res = x_malloc((len + 1) * sizeof(wchar_t));
+ res = s_malloc(wchar_t, len + 1);
if (!res)
return NULL;
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
@@ -360,7 +360,7 @@
szAnsi, -1, NULL, 0);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return NULL;
- if (!(szWide = (LPWSTR)x_malloc(sizeof(WCHAR) * (dwLength + 1))))
+ if (!(szWide = s_malloc(WCHAR, dwLength + 1)))
return NULL;
}
if (MultiByteToWideChar(dwCp, MB_ERR_INVALID_CHARS,
@@ -377,7 +377,7 @@
NULL, 0, NULL, NULL);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return NULL;
- if (!(szAnsi = (LPSTR)x_malloc(dwLength + 1)))
+ if (!(szAnsi = s_malloc(CHAR, dwLength + 1)))
return NULL;
}
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Tue Sep 15 21:21:51 2009
@@ -257,7 +257,7 @@
ACR_DECLARE(void **) ACR_Aalloc(JNIEnv *_E, const char *file, int line,
size_t size)
{
- void **arr = x_calloc((size + 1) * sizeof(void *));
+ void **arr = s_calloc(void *, size + 1);
if (!arr) {
int err = ACR_GET_OS_ERROR();
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/sbuf.c Tue Sep 15 21:21:51 2009
@@ -132,7 +132,7 @@
}
flags &= ACR_SBUF_USRFLAGMSK;
if (s == NULL) {
- s = x_calloc(sizeof(acr_sbuf_t));
+ s = s_calloc(acr_sbuf_t, 1);
if (s == NULL)
return NULL;
s->s_flags = flags;
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=815495&r1=815494&r2=815495&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Tue Sep 15 21:21:51 2009
@@ -469,7 +469,7 @@
}
else {
jchar *cc;
- if ((cc = ACR_Malloc(_E, THROW_FMARK, (l + 1) * sizeof(jchar)))) {
+ if ((cc = ACR_MALLOC(jchar, l + 1))) {
size_t i;
for (i = 0; i < l; i++) {
cc[i] = s[i];
@@ -498,7 +498,7 @@
}
else {
jchar *cc;
- if ((cc = ACR_Malloc(_E, THROW_FMARK, (sl + 1) * sizeof(jchar)))) {
+ if ((cc = ACR_MALLOC(jchar, sl + 1))) {
jsize wl = sl;
if ((ex = conv_utf8_to_ucs2(s, sl, cc, &wl)) == ACR_SUCCESS)
rs = (*_E)->NewString(_E, cc, sl);
@@ -860,7 +860,7 @@
if (b && sl < ACR_MBUFF_LEN)
rv = b;
else {
- rv = (wchar_t *)ACR_Malloc(_E, THROW_FMARK, (sl + 1) * sizeof(wchar_t));
+ rv = ACR_MALLOC(wchar_t, sl + 1);
if (!rv) {
/* Exception has already neen throw from ACR_Malloc
*/
@@ -930,7 +930,7 @@
}
else {
jchar *cc;
- if ((cc = ACR_Malloc(_E, THROW_FMARK, (l + 1) * sizeof(jchar)))) {
+ if ((cc = ACR_MALLOC(jchar, l + 1))) {
size_t i;
for (i = 0; i < l; i++) {
/* Simply assign utf32 to utf16 */