/**************************************************************************/
/*                                                                        */
/*                                 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: b_badj.c,v 1.2 1997/09/25 16:56:36 ae59 Exp $ */
/*
$Log: b_badj.c,v $
 * Revision 1.2  1997/09/25  16:56:36  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:21:01  ae59
 * Put under RCS control
 *
 */
/************************************************************************/
/*                                                                      */
/* Descriptive Name : b_badj.c          Processor : C                   */
/*                                                                      */
/* Adjust length of mantissa of an intern variable                      */
/*                                                                      */
/* Function value : int     0 - intern variable allocated               */
/*                      ALLOC - allocation error                        */
/*                                                                      */
/*      Date            : 1990-07-16                    */
/*      1990-07-16 : LINT_ARGS prototype                */
/********************************************************/

#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 int b_badj(a_btyp n,multiprecision i)
#else
local int b_badj(n,i)

a_btyp n;               /* length of mantissa to be allocated           */
multiprecision i;       /* pointer to intern variable                   */
#endif
        {
/*----------------------------------------------------------------------*/
        if (n<=0)
           {
           if (i->l)
              {
              i->l = 0;
#ifdef HEAP_CHECK
b_freh((a_char *)&i->m,(a_char *)i->m,(a_char *)"b_badj");
#endif
              B_FREE(i->m);
              }
           }
        else if (i->l!=n)
           {
           if (i->l)
              {
              i->l = 0;
#ifdef HEAP_CHECK
b_freh((a_char *)&i->m,(a_char *)i->m,(a_char *)"b_badj");
#endif
              B_FREE(i->m);
              }
           if (b_ball(n,&i->m)) return(ALLOC);
           i->l = n;
           }
/*----------------------------------------------------------------------*/
        return(0);
        }
