universe@114: /** universe@114: * @mainpage UAP Common Extensions universe@114: * Library with common and useful functions, macros and data structures. universe@114: *

universe@259: * Latest available source:
universe@259: * universe@259: * https://sourceforge.net/projects/ucx/files/ universe@259: *

universe@259: * universe@259: *

universe@259: * Repositories:
universe@263: * universe@263: * https://sourceforge.net/p/ucx/code universe@259: * - or - universe@114: * universe@114: * https://develop.uap-core.de/hg/ucx universe@114: *

universe@114: * universe@114: *

LICENCE

universe@114: * universe@259: * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. universe@114: * universe@114: * Redistribution and use in source and binary forms, with or without universe@114: * modification, are permitted provided that the following conditions are met: universe@114: * universe@114: * 1. Redistributions of source code must retain the above copyright universe@114: * notice, this list of conditions and the following disclaimer. universe@114: * universe@114: * 2. Redistributions in binary form must reproduce the above copyright universe@114: * notice, this list of conditions and the following disclaimer in the universe@114: * documentation and/or other materials provided with the distribution. universe@114: * universe@114: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@114: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@114: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@114: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@114: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@114: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@114: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@114: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@114: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@114: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@114: * POSSIBILITY OF SUCH DAMAGE. universe@114: */ universe@114: universe@251: #include "ucx/ucx.h" olaf@270: olaf@331: int ucx_szmul_impl(size_t a, size_t b, size_t *result) { olaf@270: if(a == 0 || b == 0) { olaf@270: *result = 0; universe@273: return 0; olaf@270: } olaf@270: size_t r = a * b; olaf@270: if(r / b == a) { olaf@270: *result = r; olaf@270: return 0; olaf@270: } else { olaf@270: *result = 0; olaf@270: return 1; olaf@270: } olaf@270: } universe@273: