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 * - or -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 without24 * modification, are permitted provided that the following conditions are met:25 *26 * 1. Redistributions of source code must retain the above copyright27 * notice, this list of conditions and the following disclaimer.28 *29 * 2. Redistributions in binary form must reproduce the above copyright30 * notice, this list of conditions and the following disclaimer in the31 * 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, THE35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE36 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE37 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR38 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF39 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS40 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN41 * 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 THE43 * 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 return0;
52 }
53 size_t r = a * b;
54 if(r / b == a) {
55 *result = r;
56 return0;
57 } else {
58 *result = 0;
59 return1;
60 }
61 }
62 63