remove -Werror from automake
[platform/upstream/libtasn1.git] / lib / gstr.h
1 /*
2  * Copyright (C) 2002-2014 Free Software Foundation, Inc.
3  *
4  * This file is part of LIBTASN1.
5  *
6  * The LIBTASN1 library is free software; you can redistribute it
7  * and/or modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA
20  */
21
22 unsigned int _asn1_str_cpy (char *dest, size_t dest_tot_size,
23                             const char *src);
24 void _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src);
25
26 #define Estrcpy(x,y) _asn1_str_cpy(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
27 #define Estrcat(x,y) _asn1_str_cat(x,ASN1_MAX_ERROR_DESCRIPTION_SIZE,y)
28
29 inline static
30 void safe_memset(void *data, int c, size_t size)
31 {
32         volatile unsigned volatile_zero = 0;
33         volatile char *vdata = (volatile char*)data;
34
35         /* This is based on a nice trick for safe memset,
36          * sent by David Jacobson in the openssl-dev mailing list.
37          */
38
39         if (size > 0) do {
40                 memset(data, c, size);
41         } while(vdata[volatile_zero] != c);
42 }