Index: abstract.c =================================================================== --- abstract.c (nonexistent) +++ abstract.c (revision 686) @@ -0,0 +1,55 @@ +/* + * COPYRIGHT + * + * cschem - modular/flexible schematics editor - libcschem (core library) + * Copyright (C) 2019 Tibor 'Igor2' Palinkas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version.* + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/cschem + * lead developer: email to cschem (at) igor2.repo.hu + * mailing list: cschem (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include +#include + +#include "abstract.h" +#include "compat.h" + +void csch_abstract_init(csch_abstract_t *abs) +{ + memset(abs, 0, sizeof(csch_abstract_t)); + htsp_init(&abs->nets, strhash, strkeyeq); +} + +csch_anet_t *csch_anet_get(csch_abstract_t *abs, const char *netname, int alloc) +{ + csch_anet_t *net; + + net = htsp_get(&abs->nets, netname); + if ((net != NULL) || (!alloc)) + return net; + + net = calloc(sizeof(csch_anet_t), 1); + net->netname = csch_strdup(netname); + htsp_set(&abs->nets, net->netname, net); + return net; +} +