-/* $OpenBSD: arc4random_win.h,v 1.5 2015/01/15 06:57:18 deraadt Exp $ */
+/* $OpenBSD: arc4random_win.h,v 1.6 2016/06/30 12:17:29 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
static inline int
_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
{
- *rsp = calloc(1, sizeof(**rsp));
+ *rsp = VirtualAlloc(NULL, sizeof(**rsp),
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (*rsp == NULL)
return (-1);
- *rsxp = calloc(1, sizeof(**rsxp));
+ *rsxp = VirtualAlloc(NULL, sizeof(**rsxp),
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (*rsxp == NULL) {
- free(*rsp);
+ VirtualFree(*rsp, 0, MEM_RELEASE);
+ *rsp = NULL;
return (-1);
}
return (0);
-/* $OpenBSD: arc4random_win.h,v 1.5 2015/01/15 06:57:18 deraadt Exp $ */
+/* $OpenBSD: arc4random_win.h,v 1.6 2016/06/30 12:17:29 bcook Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
static inline int
_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
{
- *rsp = calloc(1, sizeof(**rsp));
+ *rsp = VirtualAlloc(NULL, sizeof(**rsp),
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (*rsp == NULL)
return (-1);
- *rsxp = calloc(1, sizeof(**rsxp));
+ *rsxp = VirtualAlloc(NULL, sizeof(**rsxp),
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
if (*rsxp == NULL) {
- free(*rsp);
+ VirtualFree(*rsp, 0, MEM_RELEASE);
+ *rsp = NULL;
return (-1);
}
return (0);