summaryrefslogtreecommitdiffstats
path: root/src/jemalloc.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2012-04-30 10:38:26 (GMT)
committerJason Evans <je@fb.com>2012-04-30 23:50:55 (GMT)
commita14bce85e885f83c96116cc5438ae52d740f3727 (patch)
treeafc19981fe9e5b0de90645189626dae967733ad8 /src/jemalloc.c
parentaf04b744bda40842631d80ad04e1510308b13e54 (diff)
downloadjemalloc-a14bce85e885f83c96116cc5438ae52d740f3727.zip
jemalloc-a14bce85e885f83c96116cc5438ae52d740f3727.tar.gz
jemalloc-a14bce85e885f83c96116cc5438ae52d740f3727.tar.bz2
Use Get/SetLastError on Win32
Using errno on win32 doesn't quite work, because the value set in a shared library can't be read from e.g. an executable calling the function setting errno. At the same time, since buferror always uses errno/GetLastError, don't pass it.
Diffstat (limited to 'src/jemalloc.c')
-rw-r--r--src/jemalloc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 52296e0..cae0098 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -472,9 +472,9 @@ malloc_conf_init(void)
uintmax_t um; \
char *end; \
\
- errno = 0; \
+ set_errno(0); \
um = malloc_strtoumax(v, &end, 0); \
- if (errno != 0 || (uintptr_t)end - \
+ if (get_errno() != 0 || (uintptr_t)end -\
(uintptr_t)v != vlen) { \
malloc_conf_error( \
"Invalid conf value", \
@@ -493,9 +493,9 @@ malloc_conf_init(void)
long l; \
char *end; \
\
- errno = 0; \
+ set_errno(0); \
l = strtol(v, &end, 0); \
- if (errno != 0 || (uintptr_t)end - \
+ if (get_errno() != 0 || (uintptr_t)end -\
(uintptr_t)v != vlen) { \
malloc_conf_error( \
"Invalid conf value", \
@@ -831,7 +831,7 @@ label_oom:
"out of memory\n");
abort();
}
- errno = ENOMEM;
+ set_errno(ENOMEM);
}
if (config_prof && opt_prof && ret != NULL)
prof_malloc(ret, usize, cnt);
@@ -959,7 +959,7 @@ je_aligned_alloc(size_t alignment, size_t size)
if ((err = imemalign(&ret, alignment, size, 1)) != 0) {
ret = NULL;
- errno = err;
+ set_errno(err);
}
JEMALLOC_VALGRIND_MALLOC(err == 0, ret, isalloc(ret, config_prof),
false);
@@ -1029,7 +1029,7 @@ label_return:
"memory\n");
abort();
}
- errno = ENOMEM;
+ set_errno(ENOMEM);
}
if (config_prof && opt_prof && ret != NULL)
@@ -1130,7 +1130,7 @@ label_oom:
"out of memory\n");
abort();
}
- errno = ENOMEM;
+ set_errno(ENOMEM);
}
} else {
/* realloc(NULL, size) is equivalent to malloc(size). */
@@ -1172,7 +1172,7 @@ label_oom:
"out of memory\n");
abort();
}
- errno = ENOMEM;
+ set_errno(ENOMEM);
}
}