Pristine Ack-5.5
[Ack-5.5.git] / modules / src / alloc / Salloc.c
1 /* $Id: Salloc.c,v 1.7 1994/06/24 11:06:30 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /*      M E M O R Y  A L L O C A T I O N  R O U T I N E S       */
7
8 /*      The memory allocation routines offered in this file are:
9
10         char *Salloc(str, n)    : allocate n bytes, initialized with the string
11                                         str
12 */
13
14 #if __STDC__
15 #include <stdlib.h>
16 #else
17 extern char *malloc();
18 #endif
19
20 #include        "alloc.h"
21
22 char *
23 Salloc(str, sz)
24         register char *str;
25         register unsigned int sz;
26 {
27         /*      Salloc() is not a primitive function: it just allocates a
28                 piece of storage and copies a given string into it.
29         */
30         char *res = malloc(sz);
31         register char *m = res;
32
33         if (sz && m == 0) No_Mem();
34         while (sz--)
35                 *m++ = *str++;
36         return res;
37 }