From 7bee475de17e96064d26b3cfa9927c29c829c919 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Thu, 5 Mar 2020 13:15:52 +0100 Subject: [PATCH] Instantiations of string and dstring functions as inline This will remove the redundant-decls warning --- src/misc/dstring.c | 28 ++++++++++++++-------------- src/misc/string.c | 10 +++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/misc/dstring.c b/src/misc/dstring.c index 51df2f55a..a02de3078 100644 --- a/src/misc/dstring.c +++ b/src/misc/dstring.c @@ -15,17 +15,17 @@ DESCRIPTION:This file contains the routines for manipulating dynamic strings. static int ds_reserve_internal(DSTRING *p_ds, size_t n_byte_alloc_opt, size_t n_byte_alloc_min); -/* Instantiations of dstring functions in case inlining is not performed */ -int ds_cat_str(DSTRING *p_ds, const char *sz); -int ds_cat_char(DSTRING *p_ds, char c); -int ds_cat_ds(DSTRING *p_ds_dst, const DSTRING *p_ds_src); -int ds_cat_mem(DSTRING *p_ds, const char *p_src, size_t n_char); -int ds_set_length(DSTRING *p_ds, size_t length); -void ds_clear(DSTRING *p_ds); -char *ds_free_move(DSTRING *p_ds, unsigned int opt); -char *ds_get_buf(DSTRING *p_ds); -size_t ds_get_length(const DSTRING *p_ds); -size_t ds_get_buf_size(const DSTRING *p_ds); +/* Instantiations of dstring functions */ +extern inline int ds_cat_str(DSTRING *p_ds, const char *sz); +extern inline int ds_cat_char(DSTRING *p_ds, char c); +extern inline int ds_cat_ds(DSTRING *p_ds_dst, const DSTRING *p_ds_src); +extern inline int ds_cat_mem(DSTRING *p_ds, const char *p_src, size_t n_char); +extern inline int ds_set_length(DSTRING *p_ds, size_t length); +extern inline void ds_clear(DSTRING *p_ds); +extern inline char *ds_free_move(DSTRING *p_ds, unsigned int opt); +extern inline char *ds_get_buf(DSTRING *p_ds); +extern inline size_t ds_get_length(const DSTRING *p_ds); +extern inline size_t ds_get_buf_size(const DSTRING *p_ds); /* This function initalizes a dstring using *p_buf as the initial backing @@ -85,7 +85,7 @@ int ds_init(DSTRING *p_ds, char *p_buf, size_t length_string, void ds_free(DSTRING *p_ds) { if (p_ds->p_buf != p_ds->p_stack_buf) { - free((void *) p_ds->p_buf); + txfree((void *) p_ds->p_buf); } } /* end of function ds_free */ @@ -229,7 +229,7 @@ static int ds_reserve_internal(DSTRING *p_ds, /* If there already was a dynamic allocation, free it */ if (p_ds->p_buf != p_ds->p_stack_buf) { - free((void *) p_ds->p_buf); + txfree((void *) p_ds->p_buf); } /* Assign new active buffer and its size */ @@ -333,7 +333,7 @@ int ds_compact(DSTRING *p_ds) * free the allocation. */ if (p_ds->n_byte_stack_buf >= n_byte_alloc_min) { (void) memcpy(p_ds->p_stack_buf, p_ds->p_buf, n_byte_alloc_min); - free((void *) p_ds->p_buf); + txfree((void *) p_ds->p_buf); p_ds->p_buf = p_ds->p_stack_buf; p_ds->n_byte_alloc = p_ds->n_byte_stack_buf; return DS_E_OK; diff --git a/src/misc/string.c b/src/misc/string.c index 2b9cf1c29..a3d1dfe12 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -14,11 +14,11 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include "ngspice/dstring.h" -/* Instantiations of string functions in case inlining is not performed */ -char *copy(const char *str); -char *copy_substring(const char *str, const char *end); -int scannum(const char *str); -int substring(const char *sub, const char *str); +/* Instantiations of string functions */ +extern inline char *copy(const char *str); +extern inline char *copy_substring(const char *str, const char *end); +extern inline int scannum(const char *str); +extern inline int substring(const char *sub, const char *str);