/********************************************
copyright 1991, Michael D. Brennan
This is a source file for mawk, an implementation of
the AWK programming language.
Mawk is distributed without warranty under the terms of
the GNU General Public License, version 2, 1991.
********************************************/
* Revision 5.1 91/12/05 07:56:21 brennan
#define SUPPRESS_NEW_STRING_PROTO /* get compiler off our back on
the definition of new_STRING() */
STRING null_str
= {0, 1, "" } ;
STRING
*new_STRING(s
, xlen
)
char *s
; unsigned xlen
;
/* WARNING: if s != NULL, don't access xlen
because it won't be there */
{ register STRING
*sval
;
if ( *s
== 0 ){ sval
= &null_str
; null_str
.ref_cnt
++ ; }
sval
= (STRING
*) zmalloc(len
+ STRING_OH
) ;
(void) strcpy(sval
->str
, s
) ;
{ sval
= (STRING
*) zmalloc( xlen
+ STRING_OH
) ;
sval
->ref_cnt
= 1 ; sval
->len
= xlen
;
/* zero out the end marker */
void DB_free_STRING(sval
)
{ if ( -- sval
->ref_cnt
== 0 ) zfree(sval
, sval
->len
+STRING_OH
) ; }