source: trunk/kProfile/dbgsymbol.cpp@ 3526

Last change on this file since 3526 was 3526, checked in by bird, 18 years ago

made it build again.

File size: 2.3 KB
Line 
1/* $Id: $ */
2/** @file
3 *
4 * kProfile Mark 2 - Debug Info Symbol.
5 *
6 * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de>
7 *
8 *
9 * This file is part of kLIBC.
10 *
11 * kLIBC is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * kLIBC is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kLIBC; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include <iprt/err.h>
32#include <iprt/assert.h>
33#include <iprt/alloc.h>
34
35#include "kDbgBase.h"
36#include "dbg.h"
37
38
39/**
40 * Duplicates a symbol.
41 *
42 * To save heap space, the returned symbol will not own more heap space than
43 * it strictly need to. So, it's not possible to append stuff to the symbol
44 * or anything of that kind.
45 *
46 * @returns Pointer to the duplicate.
47 * This must be freed using RTDbgSymbolFree().
48 * @param pSymbol The symbol to be duplicated.
49 */
50RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymbol)
51{
52 AssertMsgReturn(VALID_PTR(pSymbol), ("%p\n", pSymbol), NULL);
53 size_t cb = KDBG_OFFSETOF(RTDBGSYMBOL, szName[pSymbol->cchName + 1]);
54 return (PRTDBGSYMBOL)RTMemDup(pSymbol, cb);
55}
56
57
58/**
59 * Frees a symbol obtained from the RTDbg API.
60 *
61 * @returns VINF_SUCCESS on success.
62 * @returns VERR_INVALID_POINTER if a NULL pointer or an !VALID_PTR() is passed in.
63 *
64 * @param pSymbol The symbol to be freed.
65 */
66RTDECL(int) RTDbgSymbolFree(PRTDBGSYMBOL pSymbol)
67{
68 if (!pSymbol)
69 return VERR_INVALID_POINTER;
70 AssertMsgReturn(VALID_PTR(pSymbol), ("%p\n", pSymbol), VERR_INVALID_POINTER);
71
72 RTMemFree(pSymbol);
73 return VINF_SUCCESS;
74}
75
Note: See TracBrowser for help on using the repository browser.