|
|
1.1 root 1: /* Allocate memory region filled with spaces.
2: Copyright (C) 1991 Free Software Foundation, Inc.
3:
4: This file is part of the libiberty library.
5: Libiberty is free software; you can redistribute it and/or
6: modify it under the terms of the GNU Library General Public
7: License as published by the Free Software Foundation; either
8: version 2 of the License, or (at your option) any later version.
9:
10: Libiberty is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: Library General Public License for more details.
14:
15: You should have received a copy of the GNU Library General Public
16: License along with libiberty; see the file COPYING.LIB. If
17: not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18: Cambridge, MA 02139, USA. */
19:
20: /*
21:
22: NAME
23:
24: spaces -- return a pointer to a buffer full of spaces
25:
26: SYNOPSIS
27:
28: char *spaces (int count)
29:
30: DESCRIPTION
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:
36: BUGS
37:
38: */
39:
40:
41: char *
42: spaces (count)
43: int count;
44: {
45: register char *t;
46: static char *buf;
47: static int maxsize;
48: extern char *malloc ();
49: extern void free ();
50:
51: if (count > maxsize)
52: {
53: if (buf)
54: {
55: free (buf);
56: }
57: buf = malloc (count + 1);
58: for (t = buf + count ; t != buf ; )
59: {
60: *--t = ' ';
61: }
62: maxsize = count;
63: buf[count] = '\0';
64: }
65: return (buf + maxsize - count);
66: }
67:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.