1# $OpenBSD: freenull.awk,v 1.1 2018/07/10 20:53:30 tb Exp $ 2# Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 3# 4# Permission to use, copy, modify, and distribute this software for any 5# purpose with or without fee is hereby granted, provided that the above 6# copyright notice and this permission notice appear in all copies. 7# 8# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 16# usage: awk -f freenull.awk < Symbols.list > freenull.c.body 17 18# Skip this function because it calls abort(3). 19/^CRYPTO_dbg_free/ { 20 next 21} 22 23# Skip *_free functions that take more than one or no argument. 24/^ASN1_item_ex_free$/ || 25/^ASN1_item_free$/ || 26/^ASN1_primitive_free$/ || 27/^ASN1_template_free$/ || 28/^CONF_modules_free$/ || 29/^EVP_PKEY_asn1_set_free$/ || 30/^OBJ_sigid_free$/ || 31/^X509V3_section_free$/ || 32/^X509V3_string_free$/ || 33/^asn1_enc_free$/ || 34/^sk_pop_free$/ { 35 next 36} 37 38# Skip functions that are prototyped in a .c file. 39/^BIO_CONNECT_free$/ || 40/^CRYPTO_free$/ || 41/^EC_PRIVATEKEY_free$/ || 42/^ECPARAMETERS_free$/ || 43/^ECPKPARAMETERS_free$/ || 44/^NETSCAPE_ENCRYPTED_PKEY_free$/ || 45/^NETSCAPE_PKEY_free$/ || 46/^X9_62_CHARACTERISTIC_TWO_free$/ || 47/^X9_62_PENTANOMIAL_free$/ { 48 next 49} 50 51/^ENGINE_free$/ { 52 printf("#ifndef OPENSSL_NO_ENGINE\n") 53 printf("\tENGINE_free(NULL);\n") 54 printf("#endif\n") 55 next 56} 57 58/_free$/ { 59 printf("\t%s(NULL);\n", $0) 60} 61