/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: s_init.c,v 1.2 1997/09/25 17:59:50 ae59 Exp $ */
/*
$Log: s_init.c,v $
 * Revision 1.2  1997/09/25  17:59:50  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:24:40  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : s_init.c                              */
/*                                                              */
/*      Entry           : void s_init(d,size)                   */
/*                        s_trng *d;                            */
/*                        size_t size;                          */
/*                                                              */
/*      Arguments       : d - descriptor of dynamic array       */
/*                        size - size of string                 */
/*                                                              */
/*      Description     : initialization of a dynamic array     */
/*                                                              */
/*      Date            : 1993-09-16                            */
/*      1993-09-16 : cast to char*     =b=                      */
/*      1990-12-03 : one more allocated for direct use of '\0'  */
/*      1990-11-20 : E_TPUSH+E_TPOPP                            */
/*      1990-11-06 : initialize flags with FALSE                */
/*      1990-10-31 : initialize component fix if size!=0        */
/*      1990-10-17 : new flag suba in s_trng                    */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif

#ifdef LINT_ARGS
local void s_init(s_trng *d,size_t size)
#else
local void s_init(d,size)

s_trng *d;
size_t size;
#endif
        {
        E_TPUSH("s_init")

        d->alen = d->clen = 0;
        d->tmp = d->suba = d->fix = FALSE;
        if (size<=0)
           {
           size = 0;
           d->ptr = NULL;
           }

        /* one more allocated for direct use of '\0'    */
        else if ((d->ptr = (char*) malloc(size+1))==NULL)
           e_trap(ALLOCATION,2,E_TMSG,54);
        else
           {
           d->fix = TRUE;
           d->alen = size;
#ifdef HEAP_CHECK
b_geth((a_char *)&d->ptr,(a_char *)d->ptr,(a_char *)"s_init");
#endif
           }

        E_TPOPP("s_init")
        return;
        }
