ucx/ucx.c

changeset 0
804d8803eade
equal deleted inserted replaced
-1:000000000000 0:804d8803eade
1 /**
2 * @mainpage UAP Common Extensions
3 * Library with common and useful functions, macros and data structures.
4 * <p>
5 * Latest available source:<br>
6 * <a href="https://sourceforge.net/projects/ucx/files/">
7 * https://sourceforge.net/projects/ucx/files/</a>
8 * </p>
9 *
10 * <p>
11 * Repositories:<br>
12 * <a href="https://sourceforge.net/p/ucx/code">
13 * https://sourceforge.net/p/ucx/code</a>
14 * -&nbsp;or&nbsp;-
15 * <a href="https://develop.uap-core.de/hg/ucx">
16 * https://develop.uap-core.de/hg/ucx</a>
17 * </p>
18 *
19 * <h2>LICENCE</h2>
20 *
21 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions are met:
25 *
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 *
29 * 2. Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 *
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
34 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
37 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
38 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
40 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
41 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGE.
44 */
45
46 #include "ucx/ucx.h"
47
48 int ucx_szmul_impl(size_t a, size_t b, size_t *result) {
49 if(a == 0 || b == 0) {
50 *result = 0;
51 return 0;
52 }
53 size_t r = a * b;
54 if(r / b == a) {
55 *result = r;
56 return 0;
57 } else {
58 *result = 0;
59 return 1;
60 }
61 }
62

mercurial