librsync  2.3.4
util.h
Go to the documentation of this file.
1/*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 *
3 * librsync -- library for network deltas
4 *
5 * Copyright (C) 1999, 2000, 2001 by Martin Pool <mbp@sourcefrog.net>
6 * Copyright (C) 1999 by Andrew Tridgell <tridge@samba.org>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23/** \file util.h
24 * Misc utility functions used by librsync. */
25#ifndef UTIL_H
26# define UTIL_H
27
28# include <stddef.h>
29# include "librsync.h"
30
31void *rs_alloc(size_t size, char const *name);
32void *rs_realloc(void *ptr, size_t size, char const *name);
33void *rs_alloc_struct0(size_t size, char const *name);
34
35void rs_bzero(void *buf, size_t size);
36
37int rs_long_ln2(rs_long_t v);
38int rs_long_sqrt(rs_long_t v);
39
40/** Allocate and zero-fill an instance of TYPE. */
41# define rs_alloc_struct(type) \
42 ((type *) rs_alloc_struct0(sizeof(type), #type))
43
44# ifdef __GNUC__
45# define UNUSED(x) x __attribute__((unused))
46# elif defined(__LCLINT__) || defined(S_SPLINT_S)
47# define UNUSED(x) /*@unused@*/ x
48# else /* !__GNUC__ && !__LCLINT__ */
49# define UNUSED(x) x
50# endif /* !__GNUC__ && !__LCLINT__ */
51
52#endif /* !UTIL_H */
Public header for librsync.