@@ -776,6 +776,30 @@ static int expand_chars(const void *buf, const int buf_size,
776
776
return out_p - out ;
777
777
}
778
778
779
+ /*
780
+ * static void *get_pnt_start
781
+ *
782
+ * With a slot, return the user start pointer.
783
+ *
784
+ * ARGUMENTS:
785
+ *
786
+ * slot_p -> Pointer to a slot structure that we are getting info on.
787
+ */
788
+ static void * get_pnt_start (const skip_alloc_t * slot_p )
789
+ {
790
+ if (BIT_IS_SET (slot_p -> sa_flags , ALLOC_FLAG_FENCE )) {
791
+ if (BIT_IS_SET (slot_p -> sa_flags , ALLOC_FLAG_VALLOC )) {
792
+ return (char * )slot_p -> sa_mem + BLOCK_SIZE ;
793
+ }
794
+ else {
795
+ return (char * )slot_p -> sa_mem + FENCE_BOTTOM_SIZE ;
796
+ }
797
+ }
798
+ else {
799
+ return slot_p -> sa_mem ;
800
+ }
801
+ }
802
+
779
803
/*
780
804
* static void get_pnt_info
781
805
*
@@ -941,7 +965,6 @@ static void log_error_info(const char *now_file,
941
965
const void * start_user ;
942
966
unsigned int prev_line , user_size ;
943
967
skip_alloc_t * other_p ;
944
- pnt_info_t pnt_info ;
945
968
int out_len , dump_size , offset ;
946
969
947
970
if (slot_p == NULL ) {
@@ -955,8 +978,7 @@ static void log_error_info(const char *now_file,
955
978
prev_line = slot_p -> sa_line ;
956
979
user_size = slot_p -> sa_user_size ;
957
980
if (user_pnt == NULL ) {
958
- get_pnt_info (slot_p , & pnt_info );
959
- start_user = pnt_info .pi_user_start ;
981
+ start_user = get_pnt_start (slot_p );
960
982
}
961
983
else {
962
984
start_user = user_pnt ;
@@ -2423,9 +2445,7 @@ int _dmalloc_chunk_free(const char *file, const unsigned int line,
2423
2445
del_p = del_p -> sa_next_p [0 ]) {
2424
2446
if (del_p -> sa_mem <= user_pnt
2425
2447
&& (char * )del_p -> sa_mem + del_p -> sa_total_size > (char * )user_pnt ) {
2426
- pnt_info_t info ;
2427
- get_pnt_info (del_p , & info );
2428
- if (info .pi_user_start == user_pnt ) {
2448
+ if (user_pnt == get_pnt_start (del_p )) {
2429
2449
dmalloc_errno = DMALLOC_ERROR_ALREADY_FREE ;
2430
2450
}
2431
2451
else {
@@ -2810,7 +2830,7 @@ void _dmalloc_chunk_log_changed(const unsigned long mark,
2810
2830
const int log_freed_b , const int details_b )
2811
2831
{
2812
2832
skip_alloc_t * slot_p ;
2813
- pnt_info_t pnt_info ;
2833
+ void * pnt_start ;
2814
2834
int known_b , freed_b , used_b ;
2815
2835
char out [DUMP_SPACE * 4 ], * which_str ;
2816
2836
char where_buf [MAX_FILE_LENGTH + 64 ], disp_buf [64 ];
@@ -2901,13 +2921,13 @@ void _dmalloc_chunk_log_changed(const unsigned long mark,
2901
2921
known_b = 1 ;
2902
2922
}
2903
2923
2904
- get_pnt_info (slot_p , & pnt_info );
2924
+ pnt_start = get_pnt_start (slot_p );
2905
2925
2906
2926
if (known_b || (! BIT_IS_SET (_dmalloc_flags , DMALLOC_DEBUG_LOG_KNOWN ))) {
2907
2927
if (details_b ) {
2908
2928
dmalloc_message (" %s freed: '%s' (%u bytes) from '%s'" ,
2909
2929
(freed_b ? " " : "not" ),
2910
- display_pnt (pnt_info . pi_user_start , slot_p , disp_buf ,
2930
+ display_pnt (pnt_start , slot_p , disp_buf ,
2911
2931
sizeof (disp_buf )),
2912
2932
slot_p -> sa_user_size ,
2913
2933
_dmalloc_chunk_desc_pnt (where_buf , sizeof (where_buf ),
@@ -2916,10 +2936,10 @@ void _dmalloc_chunk_log_changed(const unsigned long mark,
2916
2936
2917
2937
if ((! freed_b )
2918
2938
&& BIT_IS_SET (_dmalloc_flags , DMALLOC_DEBUG_LOG_NONFREE_SPACE )) {
2919
- out_len = expand_chars ((char * )pnt_info . pi_user_start , DUMP_SPACE ,
2939
+ out_len = expand_chars ((char * )pnt_start , DUMP_SPACE ,
2920
2940
out , sizeof (out ));
2921
2941
dmalloc_message (" dump of '%p': '%.*s'" ,
2922
- pnt_info . pi_user_start , out_len , out );
2942
+ pnt_start , out_len , out );
2923
2943
}
2924
2944
}
2925
2945
_dmalloc_table_insert (& mem_table_changed , slot_p -> sa_file ,
0 commit comments