VirtualBox

source: kStuff/trunk/kDbg/kDbgLine.cpp@ 2

Last change on this file since 2 was 2, checked in by bird, 17 years ago

Imported http://svn.netlabs.org/repos/libc/trunk/kStuff, revision 3612.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.6 KB
Line 
1/* $Id: kDbgLine.cpp 2 2007-11-16 16:07:14Z bird $ */
2/** @file
3 * kDbg - The Debug Info Read, Line Numbers.
4 */
5
6/*
7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-kStuff-spam@anduin.net>
8 *
9 * This file is part of kStuff.
10 *
11 * kStuff is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * In addition to the permissions in the GNU Lesser General Public
17 * License, you are granted unlimited permission to link the compiled
18 * version of this file into combinations with other programs, and to
19 * distribute those combinations without any restriction coming from
20 * the use of this file.
21 *
22 * kStuff is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with kStuff; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 * 02110-1301, USA
31 */
32
33/*******************************************************************************
34* Header Files *
35*******************************************************************************/
36#include "kDbgInternal.h"
37#include <k/kHlpAlloc.h>
38
39
40/**
41 * Duplicates a line number.
42 *
43 * To save heap space, the returned line number will not own more heap space
44 * than it strictly need to. So, it's not possible to append stuff to the symbol
45 * or anything of that kind.
46 *
47 * @returns Pointer to the duplicate.
48 * This must be freed using kDbgSymbolFree().
49 * @param pLine The line number to be duplicated.
50 */
51KDBG_DECL(PKDBGLINE) kDbgLineDup(PCKDBGLINE pLine)
52{
53 kDbgAssertPtrReturn(pLine, NULL);
54 KSIZE cb = K_OFFSETOF(KDBGLINE, szFile[pLine->cchFile + 1]);
55 PKDBGLINE pNewLine = (PKDBGLINE)kHlpDup(pLine, cb);
56 if (pNewLine)
57 pNewLine->cbSelf = cb;
58 return pNewLine;
59}
60
61
62/**
63 * Frees a line number obtained from the kDbg API.
64 *
65 * @returns 0 on success.
66 * @returns KERR_INVALID_POINTER if pLine isn't a valid pointer.
67 *
68 * @param pLine The line number to be freed. The null pointer is ignored.
69 */
70KDBG_DECL(int) kDbgLineFree(PKDBGLINE pLine)
71{
72 if (pLine)
73 {
74 kDbgAssertPtrReturn(pLine, KERR_INVALID_POINTER);
75 pLine->cbSelf = 0;
76 kHlpFree(pLine);
77 }
78 return 0;
79}
80
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette