Loading...
include/malloc/malloc.h libmalloc-792.1.1 libmalloc-792.60.6
--- libmalloc/libmalloc-792.1.1/include/malloc/malloc.h
+++ libmalloc/libmalloc-792.60.6/include/malloc/malloc.h
@@ -87,9 +87,18 @@
  * Zero out the allocated memory, similar to calloc().
  *
  */
+#if HEADER_MTE
+/*!
+ * @constant MALLOC_ZONE_MALLOC_OPTION_CANONICAL_TAG
+ * Under MTE, use a tag of zero (canonical) instead of a random value.
+ */
+#endif // HEADER_MTE
 typedef enum __enum_options : uint64_t {
 	MALLOC_ZONE_MALLOC_OPTION_NONE = 0u,
 	MALLOC_ZONE_MALLOC_OPTION_CLEAR MALLOC_SWIFT_NAME(clear) = 1u << 0,
+#if HEADER_MTE
+	MALLOC_ZONE_MALLOC_OPTION_CANONICAL_TAG MALLOC_SWIFT_NAME(canonicalTag) = 1u << 1,
+#endif // HEADER_MTE
 } malloc_zone_malloc_options_t;
 
 /*!
@@ -104,6 +113,10 @@
 __API_AVAILABLE(macos(16.0), ios(19.0), tvos(19.0), watchos(12.0), bridgeos(10.0), visionos(3.0), driverkit(25.0))
 void * __sized_by_or_null(size) malloc_type_zone_malloc_with_options(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id, malloc_zone_malloc_options_t opts) __result_use_check __alloc_align(2) __alloc_size(3);
 #endif /* __LP64__ */
+
+#if defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING
+static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_malloc_with_options_backdeploy(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id, malloc_zone_malloc_options_t opts) __result_use_check __alloc_align(2) __alloc_size(3);
+#endif /* defined(_MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING) && _MALLOC_TYPE_MALLOC_IS_BACKDEPLOYING */
 
 // The remainder of these functions are declared in malloc/_malloc_type.h, and
 // the backdeployment variant definitions are at the bottom of this file.
@@ -404,13 +417,16 @@
  * parameter may be NULL, in which case the default zone will be used.
  *
  * @param align
- * The minimum alignment of the requested allocation. This parameter must be
- * MALLOC_ZONE_MALLOC_DEFAULT_ALIGN to request default alignment, or a power
- * of 2 >= sizeof(void *).
+ * The minimum alignment of the requested allocation. This non-zero parameter
+ * must be MALLOC_ZONE_MALLOC_DEFAULT_ALIGN to request default alignment, or a
+ * power of 2 > sizeof(void *).
  *
  * @param size
- * The size, in bytes, of the requested allocation. Must be an integral
- * multiple of align if align is non-zero.
+ * The size, in bytes, of the requested allocation, which must be an integral
+ * multiple of align. This requirement is relaxed slightly on OS versions
+ * strictly newer than 26.0, where a non-multiple size is permitted if and only
+ * if align is MALLOC_ZONE_MALLOC_DEFAULT_ALIGN. OS version 26.0 does not
+ * implement this exception.
  *
  * @param options
  * A bitmask of options defining how the memory should be allocated. See the
@@ -693,6 +709,15 @@
 	return func(zone, size);
 }
 
+static void * __sized_by_or_null(size) __attribute__((always_inline)) malloc_type_zone_malloc_with_options_backdeploy(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id, malloc_zone_malloc_options_t opts) __result_use_check __alloc_align(2) __alloc_size(3) {
+	__attribute__((weak_import)) void * __sized_by_or_null(size) malloc_type_zone_malloc_with_options(malloc_zone_t *zone, size_t alignment, size_t size, malloc_type_id_t type_id, malloc_zone_malloc_options_t opts) __result_use_check __alloc_align(2) __alloc_size(3);
+	__auto_type func = malloc_zone_malloc_with_options;
+	if (malloc_type_zone_malloc_with_options) {
+		return malloc_type_zone_malloc_with_options(zone, alignment, size, type_id, opts);
+	}
+	return func(zone, alignment, size, opts);
+}
+
 static void * __sized_by_or_null(count * size) __attribute__((always_inline)) malloc_type_zone_calloc_backdeploy(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3) {
 	__attribute__((weak_import)) void * __sized_by_or_null(count * size) malloc_type_zone_calloc(malloc_zone_t *zone, size_t count, size_t size, malloc_type_id_t type_id) __result_use_check __alloc_size(2,3);
 	__auto_type func = malloc_zone_calloc;