~ubuntu-branches/ubuntu/trusty/virtualbox-lts-xenial/trusty-updates

« back to all changes in this revision

Viewing changes to src/VBox/Runtime/r3/win/rtmemlocked-win.cpp

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2016-02-23 14:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20160223142826-bdu69el2z6wa2a44
Tags: upstream-4.3.36-dfsg
ImportĀ upstreamĀ versionĀ 4.3.36-dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: rtmemlocked-win.cpp $ */
 
2
/** @file
 
3
 * IPRT - RTMemLocked*, POSIX.
 
4
 */
 
5
 
 
6
/*
 
7
 * Copyright (C) 2014 Oracle Corporation
 
8
 *
 
9
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
10
 * available from http://www.virtualbox.org. This file is free software;
 
11
 * you can redistribute it and/or modify it under the terms of the GNU
 
12
 * General Public License (GPL) as published by the Free Software
 
13
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
14
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
15
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
16
 *
 
17
 * The contents of this file may alternatively be used under the terms
 
18
 * of the Common Development and Distribution License Version 1.0
 
19
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 
20
 * VirtualBox OSE distribution, in which case the provisions of the
 
21
 * CDDL are applicable instead of those of the GPL.
 
22
 *
 
23
 * You may elect to license modified versions of this file under the
 
24
 * terms and conditions of either the GPL or the CDDL or both.
 
25
 */
 
26
 
 
27
 
 
28
/*******************************************************************************
 
29
*   Header Files                                                               *
 
30
*******************************************************************************/
 
31
#define LOG_GROUP RTLOGGROUP_MEM
 
32
#include "internal/iprt.h"
 
33
#include <iprt/mem.h>
 
34
 
 
35
#include <iprt/assert.h>
 
36
#include <iprt/err.h>
 
37
#include <iprt/param.h>
 
38
#include <iprt/string.h>
 
39
#include "internal/mem.h"
 
40
 
 
41
#include <Windows.h>
 
42
 
 
43
/*******************************************************************************
 
44
*   Defined Constants And Macros                                               *
 
45
*******************************************************************************/
 
46
 
 
47
 
 
48
/*******************************************************************************
 
49
*   Structures and Typedefs                                                    *
 
50
*******************************************************************************/
 
51
 
 
52
RTDECL(int) RTMemLockedAllocExTag(size_t cb, const char *pszTag, void **ppv) RT_NO_THROW
 
53
{
 
54
    int rc = VINF_SUCCESS;
 
55
 
 
56
    *ppv = RTMemAlloc(cb);
 
57
    if (!*ppv)
 
58
        rc = VERR_NO_MEMORY;
 
59
 
 
60
    return rc;
 
61
}
 
62
 
 
63
RTDECL(int) RTMemLockedAllocZExTag(size_t cb, const char *pszTag, void **ppv) RT_NO_THROW
 
64
{
 
65
    void *pv = NULL;
 
66
    int rc = RTMemLockedAllocExTag(cb, pszTag, &pv);
 
67
 
 
68
    if (RT_SUCCESS(rc))
 
69
    {
 
70
        RT_BZERO(pv, cb);
 
71
        *ppv = pv;
 
72
    }
 
73
 
 
74
    return rc;
 
75
}
 
76
 
 
77
RTDECL(void *) RTMemLockedAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 
78
{
 
79
    void *pv = NULL;
 
80
    int rc = RTMemLockedAllocExTag(cb, pszTag, &pv);
 
81
 
 
82
    if (RT_FAILURE(rc))
 
83
        return NULL;
 
84
 
 
85
    return pv;
 
86
}
 
87
 
 
88
RTDECL(void *) RTMemLockedAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
 
89
{
 
90
    void *pv = NULL;
 
91
    int rc = RTMemLockedAllocZExTag(cb, pszTag, &pv);
 
92
 
 
93
    if (RT_FAILURE(rc))
 
94
        return NULL;
 
95
 
 
96
    return pv;
 
97
}
 
98
 
 
99
RTDECL(void) RTMemLockedFree(void *pv) RT_NO_THROW
 
100
{
 
101
    /*
 
102
     * Validate & adjust the input.
 
103
     */
 
104
    if (!pv)
 
105
        return;
 
106
    AssertPtr(pv);
 
107
 
 
108
    RTMemFree(pv);
 
109
}
 
110