/* $Id: kDbgLine.cpp 3528 2007-08-20 02:43:13Z bird $ */ /** @file * kDbg - The Debug Info Read, Line Numbers. */ /* * Copyright (c) 2006-2007 knut st. osmundsen * * This file is part of kLIBC. * * kLIBC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * kLIBC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with kLIBC; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /******************************************************************************* * Header Files * *******************************************************************************/ #include "kDbg.h" #include "kDbgInternal.h" /** * Duplicates a line number. * * To save heap space, the returned line number will not own more heap space * than it strictly need to. So, it's not possible to append stuff to the symbol * or anything of that kind. * * @returns Pointer to the duplicate. * This must be freed using kDbgSymbolFree(). * @param pLine The line number to be duplicated. */ KDBG_DECL(PKDBGLINE) kDbgLineDup(PCKDBGLINE pLine) { kDbgAssertMsgReturn(KDBG_VALID_PTR(pLine), ("%p\n", pLine), NULL); size_t cb = KDBG_OFFSETOF(KDBGLINE, szFile[pLine->cchFile + 1]); return (PKDBGLINE)kDbgHlpAllocDup(pLine, cb); } /** * Frees a line number obtained from the RTDbg API. * * @returns 0 on success. * @returns KDBG_ERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in. * * @param pLine The line number to be freed. */ KDBG_DECL(int) kDbgLineFree(PKDBGLINE pLine) { if (!pLine) return KDBG_ERR_INVALID_POINTER; kDbgAssertMsgReturn(KDBG_VALID_PTR(pLine), ("%p\n", pLine), KDBG_ERR_INVALID_POINTER); kDbgHlpFree(pLine); return 0; }