librsync  2.0.1
util.c
1 /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  *
3  * librsync -- the library for network deltas
4  *
5  * Copyright (C) 2000, 2001 by Martin Pool <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 
22 
23  /*
24  | On heroin, I have all the answers.
25  */
26 
27 
28 #include "config.h"
29 
30 #include <stdlib.h>
31 #include <string.h>
32 #include <stdio.h>
33 
34 #include "util.h"
35 #include "librsync.h"
36 #include "trace.h"
37 
38 void
39 rs_bzero(void *buf, size_t size)
40 {
41  memset(buf, 0, size);
42 }
43 
44 
45 void *
46 rs_alloc_struct0(size_t size, char const *name)
47 {
48  void *p;
49 
50  if (!(p = malloc(size))) {
51  rs_fatal("couldn't allocate instance of %s", name);
52  }
53  rs_bzero(p, size);
54  return p;
55 }
56 
57 
58 
59 void *
60 rs_alloc(size_t size, char const *name)
61 {
62  void *p;
63 
64  if (!(p = malloc(size))) {
65  rs_fatal("couldn't allocate instance of %s", name);
66  }
67 
68  return p;
69 }
Public header for librsync.