Commit Graph

15 Commits

Author SHA1 Message Date
Joseph Sutton
ef059b8831 heimdal:base: Don't perform arithmetic on a NULL pointer
Doing so is undefined behaviour.

Change-Id: Ic57baac0fc5fb06945c0dfbd5d4eb913a12fc13d
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-01-18 00:31:45 -05:00
Nicolas Williams
b9a915c163 base: Fix various coverity warnings 2022-01-17 16:23:36 -06:00
Luke Howard
2520c30b28 base: harmonize implementation/headers
heim_retain() should both accept and return a heim_object_t; harmonize this
across header and implementation
2022-01-08 17:40:22 +11:00
Luke Howard
97cca6f921 base: use uintptr_t for hash type
Use uintptr_t for hash type; this is consistent with CoreFoundation, which uses
32-bit integers on 32-bit platforms for the hash code, and 64-bit integers on
64-bit platforms. (libheimbase is modelled on CoreFoundation.)

Previously we used unsigned long, which would have the same behavior on
LP32/LP64 systems, but not on Windows (where unsigned long is 32-bits on 64-bit
platforms).
2022-01-06 17:21:06 +11:00
Luke Howard
bb7b4f7a94 base: use atomic load/store in reference counting
Use the new atomic load and store macros for testing and setting reference
count overflow.
2020-07-14 09:35:14 +10:00
Luke Howard
4986ebcb67 base: rename heim_base_atomic_{max,type} to ...integer_{max,type}
Rename heim_base_atomic_max to heim_base_atomic_integer_max (ditto with _type)
in order to better reflect their usage, now we have a separate
heim_base_atomic() macro for making an atomic version of any type.
2020-07-14 09:35:14 +10:00
Nicolas Williams
f38089257b Misc fixes (coverity) 2016-11-20 17:43:51 -06:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Nicolas Williams
2f0c45f784 Add thread-locals for WIN32 2016-04-15 00:16:17 -05:00
Nicolas Williams
2cac8ca703 Use pthread_once() when available 2015-11-30 14:15:47 -06:00
Luke Howard
9e359ac98f base: Windows heim_base_once_t cleanup
heim_base_once_t can just be a LONG on Windows, the structure is not needed
2015-11-30 17:34:32 +11:00
Nicolas Williams
cc0e92a3c3 base: correct Windows heim_base_once_f semantics
As implemented by Jeffrey Altman heim_base_once_f() is a variant of the
"double-checked gate lock pattern".   Full memory barriers must be used
when determining whether or not to call SwitchToThread().

Change-Id: I2f8446a56c50a37c921d6e993433c9a3f7488f50
2015-11-30 00:47:54 -05:00
Jeffrey Altman
4735faba59 base: Windows implementation of heim_base_once
Provide a Windows implementation of heim_base_once that relies upon
InterlockedCompareExchange() and SwitchToThread().

Change-Id: I9cdbda796d1a27fe1e17be63f287b10132858d7f
2015-11-29 12:15:10 -05:00
Love Hornquist Astrand
029de6cfa4 pass back an heim_error from hx509_cert_init 2012-10-07 06:33:13 -07:00
Nicolas Williams
98809e86ce Move base into lib
This involves reverting dd267e8fc3,
    but that gets lost in the move.

    This builds on Ubuntu and Windows at this time.
2012-06-20 19:32:08 -05:00