1/* $NetBSD: dwarf_pro_nametbl.m4,v 1.2 2014/03/09 16:58:04 christos Exp $ */ 2 3/*- 4 * Copyright (c) 2010 Kai Wang 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * Id: dwarf_pro_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy 29 */ 30 31define(`MAKE_NAMETBL_PRO_API',` 32Dwarf_Unsigned 33dwarf_add_$1name(Dwarf_P_Debug dbg, Dwarf_P_Die die, char *$1_name, 34 Dwarf_Error *error) 35{ 36 Dwarf_NameTbl nt; 37 Dwarf_NamePair np; 38 39 if (dbg == NULL || die == NULL || $1_name == NULL) { 40 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 41 return (0); 42 } 43 44 if (dbg->dbgp_$1s == NULL) { 45 dbg->dbgp_$1s = calloc(1, sizeof(struct _Dwarf_NameTbl)); 46 if (dbg->dbgp_$1s == NULL) { 47 DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 48 return (0); 49 } 50 STAILQ_INIT(&dbg->dbgp_$1s->nt_nplist); 51 } 52 53 nt = dbg->dbgp_$1s; 54 55 if ((np = calloc(1, sizeof(struct _Dwarf_NamePair))) == NULL) { 56 DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 57 return (0); 58 } 59 60 np->np_nt = nt; 61 np->np_die = die; 62 if ((np->np_name = strdup($1_name)) == NULL) { 63 free(np); 64 DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 65 return (0); 66 } 67 68 STAILQ_INSERT_TAIL(&nt->nt_nplist, np, np_next); 69 70 return (1); 71} 72') 73