Jelajahi Sumber

misc/balloc.h: remove unused BAllocTwoArrays, BAllocThreeArrays

ambrop7 13 tahun lalu
induk
melakukan
843a1637e1
1 mengubah file dengan 0 tambahan dan 131 penghapusan
  1. 0 131
      misc/balloc.h

+ 0 - 131
misc/balloc.h

@@ -99,48 +99,6 @@ static void * BAllocArray (size_t count, size_t bytes);
  */
 static void * BAllocArray2 (size_t count2, size_t count1, size_t bytes);
 
-/**
- * Allocates memory for two arrays as a continuous block.
- * Unused bytes are inserted to make the second array aligned for any kind
- * of object.
- * The 'count' and 'bytes' arguments are interchangeable; for performance
- * reasons, try to have the 'bytes' arguments constant.
- * 
- * @param count1 number of elements for first array
- * @param bytes1 size of element for first array
- * @param count2 number of elements for second array
- * @param bytes2 size of element for second array
- * @param out2 *out2 will receive the pointer to the second array, if successful.
- *             Must not be NULL.
- * @return on success, returns the pointer to the first array and sets *out2;
- *         the memory can be freed by calling {@link BFree} on the returned pointer.
- *         On failure, returns NULL.
- */
-static void * BAllocTwoArrays (size_t count1, size_t bytes1, size_t count2, size_t bytes2, void **out2);
-
-/**
- * Allocates memory for three arrays as a continuous block.
- * Unused bytes are inserted to make the second and third arrays aligned for any
- * kind of object.
- * The 'count' and 'bytes' arguments are interchangeable; for performance
- * reasons, try to have the 'bytes' arguments constant.
- * 
- * @param count1 number of elements for first array
- * @param bytes1 size of element for first array
- * @param count2 number of elements for second array
- * @param bytes2 size of element for second array
- * @param count3 number of elements for third array
- * @param bytes3 size of element for third array
- * @param out2 *out2 will receive the pointer to the second array, if successful.
- *             Must not be NULL.
- * @param out3 *out3 will receive the pointer to the third array, if successful.
- *             Must not be NULL.
- * @return on success, returns the pointer to the first array and sets *out2 and
- *         *out3; the memory can be freed by calling {@link BFree} on the returned
- *         pointer. On failure, returns NULL.
- */
-static void * BAllocThreeArrays (size_t count1, size_t bytes1, size_t count2, size_t bytes2, size_t count3, size_t bytes3, void **out2, void **out3);
-
 /**
  * Adds to a size_t with overflow detection.
  * 
@@ -212,95 +170,6 @@ void * BAllocArray2 (size_t count2, size_t count1, size_t bytes)
     return BAlloc(count2 * (count1 * bytes));
 }
 
-
-void * BAllocTwoArrays (size_t count1, size_t bytes1, size_t count2, size_t bytes2, void **out2)
-{
-    ASSERT(out2)
-    
-    // first array
-    if (bytes1 > 0 && count1 > SIZE_MAX / bytes1) {
-        return NULL;
-    }
-    size_t s = count1 * bytes1;
-    
-    // alignment for second array
-    size_t mod = s % BMAX_ALIGN;
-    if (mod > 0) {
-        if (BMAX_ALIGN - mod > SIZE_MAX - s) {
-            return NULL;
-        }
-        s += BMAX_ALIGN - mod;
-    }
-    
-    // second array
-    size_t pos2 = s;
-    if (bytes2 > 0 && count2 > (SIZE_MAX - s) / bytes2) {
-        return NULL;
-    }
-    s += count2 * bytes2;
-    
-    void *arr = BAlloc(s);
-    
-    if (arr) {
-        *out2 = (char *)arr + pos2;
-    }
-    
-    return arr;
-}
-
-void * BAllocThreeArrays (size_t count1, size_t bytes1, size_t count2, size_t bytes2, size_t count3, size_t bytes3, void **out2, void **out3)
-{
-    ASSERT(out2)
-    ASSERT(out2)
-    
-    // first array
-    if (bytes1 > 0 && count1 > SIZE_MAX / bytes1) {
-        return NULL;
-    }
-    size_t s = count1 * bytes1;
-    
-    // alignment for second array
-    size_t mod = s % BMAX_ALIGN;
-    if (mod > 0) {
-        if (BMAX_ALIGN - mod > SIZE_MAX - s) {
-            return NULL;
-        }
-        s += BMAX_ALIGN - mod;
-    }
-    
-    // second array
-    size_t pos2 = s;
-    if (bytes2 > 0 && count2 > (SIZE_MAX - s) / bytes2) {
-        return NULL;
-    }
-    s += count2 * bytes2;
-    
-    // alignment for third array
-    mod = s % BMAX_ALIGN;
-    if (mod > 0) {
-        if (BMAX_ALIGN - mod > SIZE_MAX - s) {
-            return NULL;
-        }
-        s += BMAX_ALIGN - mod;
-    }
-    
-    // third array
-    size_t pos3 = s;
-    if (bytes3 > 0 && count3 > (SIZE_MAX - s) / bytes3) {
-        return NULL;
-    }
-    s += count3 * bytes3;
-    
-    void *arr = BAlloc(s);
-    
-    if (arr) {
-        *out2 = (char *)arr + pos2;
-        *out3 = (char *)arr + pos3;
-    }
-    
-    return arr;
-}
-
 int BSizeAdd (size_t *s, size_t add)
 {
     ASSERT(s)