/* $Id: kDbgSymbol.cpp 3528 2007-08-20 02:43:13Z bird $ */ /** @file * kDbg - The Debug Info Reader, Symbols. */ /* * 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 symbol. * * To save heap space, the returned symbol 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 pSymbol The symbol to be duplicated. */ KDBG_DECL(PKDBGSYMBOL) kDbgSymbolDup(PCKDBGSYMBOL pSymbol) { kDbgAssertPtrReturn(pSymbol, NULL); size_t cb = KDBG_OFFSETOF(KDBGSYMBOL, szName[pSymbol->cchName + 1]); return (PKDBGSYMBOL)kDbgHlpAllocDup(pSymbol, cb); } /** * Frees a symbol 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 pSymbol The symbol to be freed. */ KDBG_DECL(int) kDbgSymbolFree(PKDBGSYMBOL pSymbol) { if (!pSymbol) return KDBG_ERR_INVALID_POINTER; kDbgAssertPtrReturn(pSymbol, KDBG_ERR_INVALID_POINTER); kDbgHlpFree(pSymbol); return 0; }