* libbfd.c (bfd_put_8): Make it of type `void'.
[deliverable/binutils-gdb.git] / libiberty / spaces.c
CommitLineData
252b5132
RH
1/* Allocate memory region filled with spaces.
2 Copyright (C) 1991 Free Software Foundation, Inc.
3
4This file is part of the libiberty library.
5Libiberty is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public
7License as published by the Free Software Foundation; either
8version 2 of the License, or (at your option) any later version.
9
10Libiberty is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
14
15You should have received a copy of the GNU Library General Public
16License along with libiberty; see the file COPYING.LIB. If
17not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18Boston, MA 02111-1307, USA. */
19
20/*
21
22NAME
23
24 spaces -- return a pointer to a buffer full of spaces
25
26SYNOPSIS
27
28 char *spaces (int count)
29
30DESCRIPTION
31
32 Returns a pointer to a memory region filled with the specified
33 number of spaces and null terminated. The returned pointer is
34 valid until at least the next call.
35
36BUGS
37
38*/
39
40#include "ansidecl.h"
41#include "libiberty.h"
42
43#if VMS
44#include <stdlib.h>
45#include <unixlib.h>
46#else
47/* For systems with larger pointers than ints, these must be declared. */
48extern PTR malloc PARAMS ((size_t));
49extern void free PARAMS ((PTR));
50#endif
51
52const char *
53spaces (count)
54 int count;
55{
56 register char *t;
57 static char *buf;
58 static int maxsize;
59
60 if (count > maxsize)
61 {
62 if (buf)
63 {
64 free (buf);
65 }
66 buf = malloc (count + 1);
67 if (buf == (char *) 0)
68 return 0;
69 for (t = buf + count ; t != buf ; )
70 {
71 *--t = ' ';
72 }
73 maxsize = count;
74 buf[count] = '\0';
75 }
76 return (const char *) (buf + maxsize - count);
77}
78
This page took 0.049296 seconds and 4 git commands to generate.