Lines Matching refs:ptr

102 static void sh_free(void *ptr);
104 static size_t sh_actual_size(char *ptr);
105 static int sh_allocated(const char *ptr);
194 void CRYPTO_secure_free(void *ptr, const char *file, int line) in CRYPTO_secure_free() argument
199 if (ptr == NULL) in CRYPTO_secure_free()
201 if (!CRYPTO_secure_allocated(ptr)) { in CRYPTO_secure_free()
202 CRYPTO_free(ptr, file, line); in CRYPTO_secure_free()
207 actual_size = sh_actual_size(ptr); in CRYPTO_secure_free()
208 CLEAR(ptr, actual_size); in CRYPTO_secure_free()
210 sh_free(ptr); in CRYPTO_secure_free()
213 CRYPTO_free(ptr, file, line); in CRYPTO_secure_free()
217 void CRYPTO_secure_clear_free(void *ptr, size_t num, in CRYPTO_secure_clear_free() argument
223 if (ptr == NULL) in CRYPTO_secure_clear_free()
225 if (!CRYPTO_secure_allocated(ptr)) { in CRYPTO_secure_clear_free()
226 OPENSSL_cleanse(ptr, num); in CRYPTO_secure_clear_free()
227 CRYPTO_free(ptr, file, line); in CRYPTO_secure_clear_free()
232 actual_size = sh_actual_size(ptr); in CRYPTO_secure_clear_free()
233 CLEAR(ptr, actual_size); in CRYPTO_secure_clear_free()
235 sh_free(ptr); in CRYPTO_secure_clear_free()
238 if (ptr == NULL) in CRYPTO_secure_clear_free()
240 OPENSSL_cleanse(ptr, num); in CRYPTO_secure_clear_free()
241 CRYPTO_free(ptr, file, line); in CRYPTO_secure_clear_free()
245 int CRYPTO_secure_allocated(const void *ptr) in CRYPTO_secure_allocated() argument
255 return sh_allocated(ptr); in CRYPTO_secure_allocated()
276 size_t CRYPTO_secure_actual_size(void *ptr) in CRYPTO_secure_actual_size() argument
283 actual_size = sh_actual_size(ptr); in CRYPTO_secure_actual_size()
344 static size_t sh_getlist(char *ptr) in sh_getlist() argument
347 size_t bit = (sh.arena_size + ptr - sh.arena) / sh.minsize; in sh_getlist()
359 static int sh_testbit(char *ptr, int list, unsigned char *table) in sh_testbit() argument
364 OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0); in sh_testbit()
365 bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list)); in sh_testbit()
370 static void sh_clearbit(char *ptr, int list, unsigned char *table) in sh_clearbit() argument
375 OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0); in sh_clearbit()
376 bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list)); in sh_clearbit()
382 static void sh_setbit(char *ptr, int list, unsigned char *table) in sh_setbit() argument
387 OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0); in sh_setbit()
388 bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list)); in sh_setbit()
394 static void sh_add_to_list(char **list, char *ptr) in sh_add_to_list() argument
399 OPENSSL_assert(WITHIN_ARENA(ptr)); in sh_add_to_list()
401 temp = (SH_LIST *)ptr; in sh_add_to_list()
411 *list = ptr; in sh_add_to_list()
414 static void sh_remove_from_list(char *ptr) in sh_remove_from_list() argument
418 temp = (SH_LIST *)ptr; in sh_remove_from_list()
613 static int sh_allocated(const char *ptr) in sh_allocated() argument
615 return WITHIN_ARENA(ptr) ? 1 : 0; in sh_allocated()
618 static char *sh_find_my_buddy(char *ptr, int list) in sh_find_my_buddy() argument
623 bit = (ONE << list) + (ptr - sh.arena) / (sh.arena_size >> list); in sh_find_my_buddy()
697 static void sh_free(void *ptr) in sh_free() argument
702 if (ptr == NULL) in sh_free()
704 OPENSSL_assert(WITHIN_ARENA(ptr)); in sh_free()
705 if (!WITHIN_ARENA(ptr)) in sh_free()
708 list = sh_getlist(ptr); in sh_free()
709 OPENSSL_assert(sh_testbit(ptr, list, sh.bittable)); in sh_free()
710 sh_clearbit(ptr, list, sh.bitmalloc); in sh_free()
711 sh_add_to_list(&sh.freelist[list], ptr); in sh_free()
714 while ((buddy = sh_find_my_buddy(ptr, list)) != NULL) { in sh_free()
715 OPENSSL_assert(ptr == sh_find_my_buddy(buddy, list)); in sh_free()
716 OPENSSL_assert(ptr != NULL); in sh_free()
717 OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc)); in sh_free()
718 sh_clearbit(ptr, list, sh.bittable); in sh_free()
719 sh_remove_from_list(ptr); in sh_free()
720 OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc)); in sh_free()
727 memset(ptr > buddy ? ptr : buddy, 0, sizeof(SH_LIST)); in sh_free()
728 if (ptr > buddy) in sh_free()
729 ptr = buddy; in sh_free()
731 OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc)); in sh_free()
732 sh_setbit(ptr, list, sh.bittable); in sh_free()
733 sh_add_to_list(&sh.freelist[list], ptr); in sh_free()
734 OPENSSL_assert(sh.freelist[list] == ptr); in sh_free()
738 static size_t sh_actual_size(char *ptr) in sh_actual_size() argument
742 OPENSSL_assert(WITHIN_ARENA(ptr)); in sh_actual_size()
743 if (!WITHIN_ARENA(ptr)) in sh_actual_size()
745 list = sh_getlist(ptr); in sh_actual_size()
746 OPENSSL_assert(sh_testbit(ptr, list, sh.bittable)); in sh_actual_size()