Fri, 07 Jul 2023 18:41:03 +0200
more doc fixes
universe@674 | 1 | /* |
universe@674 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
universe@674 | 3 | * |
universe@674 | 4 | * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved. |
universe@674 | 5 | * |
universe@674 | 6 | * Redistribution and use in source and binary forms, with or without |
universe@674 | 7 | * modification, are permitted provided that the following conditions are met: |
universe@674 | 8 | * |
universe@674 | 9 | * 1. Redistributions of source code must retain the above copyright |
universe@674 | 10 | * notice, this list of conditions and the following disclaimer. |
universe@674 | 11 | * |
universe@674 | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
universe@674 | 13 | * notice, this list of conditions and the following disclaimer in the |
universe@674 | 14 | * documentation and/or other materials provided with the distribution. |
universe@674 | 15 | * |
universe@674 | 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
universe@674 | 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
universe@674 | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
universe@674 | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
universe@674 | 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
universe@674 | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
universe@674 | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
universe@674 | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
universe@674 | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
universe@674 | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
universe@674 | 26 | * POSSIBILITY OF SUCH DAMAGE. |
universe@674 | 27 | */ |
universe@674 | 28 | |
universe@674 | 29 | int cx_szmul_impl( |
universe@674 | 30 | size_t a, |
universe@674 | 31 | size_t b, |
universe@674 | 32 | size_t *result |
universe@674 | 33 | ) { |
universe@674 | 34 | if (a == 0 || b == 0) { |
universe@674 | 35 | *result = 0; |
universe@674 | 36 | return 0; |
universe@674 | 37 | } |
universe@674 | 38 | size_t r = a * b; |
universe@674 | 39 | if (r / b == a) { |
universe@674 | 40 | *result = r; |
universe@674 | 41 | return 0; |
universe@674 | 42 | } else { |
universe@674 | 43 | *result = 0; |
universe@674 | 44 | return 1; |
universe@674 | 45 | } |
universe@674 | 46 | } |