{
struct ht_neighborhood_st *ret;
+#if !defined(OPENSSL_SMALL_FOOTPRINT)
ret = OPENSSL_aligned_alloc_array(len, sizeof(struct ht_neighborhood_st),
CACHE_LINE_BYTES, freeptr);
/* fall back to regular malloc */
- if (ret == NULL) {
+ if (ret == NULL)
+#endif
+ {
ret = *freeptr =
OPENSSL_malloc_array(len, sizeof(struct ht_neighborhood_st));
if (ret == NULL)
allows for the caller to specify an alignment value, for instances in
which the default alignment of malloc is insufficient for the caller's
needs. Note, the alignment value must be a power of 2.
-NOTES:
-
-=over 4
-
-=item *
-
-The call to OPENSSL_aligned_alloc() accepts a 3rd argument, I<freeptr>
+NOTE: the call to OPENSSL_aligned_alloc() accepts a 3rd argument, I<freeptr>
which must point to a void pointer. On some platforms, there is no available
library call to obtain memory allocations with alignment greater than what
malloc provides. In this case, OPENSSL_aligned_alloc() implements its own
allocations made by this method, the caller must return the value
in the I<freeptr> variable, rather than the returned pointer.
-=item *
-
-The call to OPENSSL_aligned_alloc() may fail for reasons other than memory
-exhaustion, depending on the underlying implementation, and, most notably,
-OpenSSL library's build configuration: for example, it always returns C<NULL>
-without setting any error if OpenSSL is built with C<OPENSSL_SMALL_FOOTPRINT>
-macro defined. Consequently, caller may need to fall back to a non-aligned
-memory allocation (and open-code the alignment routine if the alignment
-is a requirement).
-
-=back
-
OPENSSL_clear_realloc() and OPENSSL_clear_free() should be used
when the buffer at B<addr> holds sensitive information.
The old buffer is filled with zero's by calling OPENSSL_cleanse()
only on platforms that do not provide posix_memalign(3), but do provide
aligned_alloc(3).
+Before OpenSSL 4.0, the call to OPENSSL_aligned_alloc() may fail for reasons
+other than memory exhaustion or incorrect arguments, depending on the underlying
+implementation, and, most notably, OpenSSL library's build configuration:
+for example, it always returned C<NULL> without setting any error if OpenSSL
+was built with C<OPENSSL_SMALL_FOOTPRINT> macro defined. Consequently,
+the caller may need to fall back to a non-aligned memory allocation
+(and open-code the alignment routine if the alignment is a requirement).
+
=head1 COPYRIGHT
Copyright 2016-2025 The OpenSSL Project Authors. All Rights Reserved.
{ 1, SIZE_MAX / 2 + 2, SIZE_MAX / 2 + 1,
#if (defined(_BSD_SOURCE) \
|| (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)) \
- && !USE_CUSTOM_ALLOC_FNS || defined(OPENSSL_SMALL_FOOTPRINT)
+ && !USE_CUSTOM_ALLOC_FNS
EXP_OOM, EXP_OOM
#else
EXP_INT_OF, EXP_INT_OF
test_fn, test_line);
}
-#if !defined(OPENSSL_SMALL_FOOTPRINT)
/*
* aligned_alloc doesn't increment the call counts by itself, and
* OPENSSL_malloc is only called when the open-coded implementation
* is used.
*/
-# if USE_CUSTOM_ALLOC_FNS \
+#if USE_CUSTOM_ALLOC_FNS \
|| !(defined(_BSD_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L))
exp_cnt += !!(exp != EXP_INT_OF && exp != EXP_INVAL);
-# endif
-#else /* OPENSSL_SMALL_FOOTPRINT */
- exp = exp == EXP_INT_OF ? EXP_INT_OF : EXP_ZERO_SIZE;
-#endif /* !OPENSSL_SMALL_FOOTPRINT */
+#endif
/*
* There is an OPENSSL_calloc in ERR_set_debug, triggered
res = 0;
}
-#if !defined(OPENSSL_SMALL_FOOTPRINT)
if (IS_FAIL(exp) && !TEST_ptr_null(freeptr))
res = 0;
if ((exp == EXP_NONNULL) && !TEST_ptr(freeptr))
res = 0;
-#else /* OPENSSL_SMALL_FOOTPRINT */
- if (!TEST_ptr_null(ret) || !TEST_ptr_null(freeptr))
- res = 0;
-#endif /* !OPENSSL_SMALL_FOOTPRINT */
OPENSSL_free(freeptr);