1
1
/*
2
2
3
- CVector 4.2.0 MIT Licensed vector (dynamic array) library in strict C89
3
+ CVector 4.2.1 MIT Licensed vector (dynamic array) library in strict C89
4
4
http://www.robertwinkler.com/projects/cvector.html
5
5
http://www.robertwinkler.com/projects/cvector/
6
6
@@ -16,7 +16,7 @@ more practical examples:
16
16
17
17
The MIT License (MIT)
18
18
19
- Copyright (c) 2011-2024 Robert Winkler
19
+ Copyright (c) 2011-2025 Robert Winkler
20
20
21
21
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
22
22
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -602,6 +602,7 @@ void cvec_free_void(void* vec);
602
602
{ \
603
603
cvector_##TYPE* tmp = (cvector_##TYPE*)vec; \
604
604
CVEC_FREE(tmp->a); \
605
+ tmp->a = NULL; \
605
606
tmp->size = 0; \
606
607
tmp->capacity = 0; \
607
608
}
@@ -1171,7 +1172,7 @@ void cvec_free_void(void* vec);
1171
1172
} \
1172
1173
\
1173
1174
CVEC_FREE(tmp->a); \
1174
- \
1175
+ tmp->a = NULL; \
1175
1176
tmp->size = 0; \
1176
1177
tmp->capacity = 0; \
1177
1178
}
@@ -1513,11 +1514,13 @@ void cvec_free_i_heap(void* vec)
1513
1514
CVEC_FREE (tmp );
1514
1515
}
1515
1516
1516
- /** Frees the internal array and sets size and capacity to 0 */
1517
+ /** Frees the internal array and zeros out the members to maintain a
1518
+ * consistent state */
1517
1519
void cvec_free_i (void * vec )
1518
1520
{
1519
1521
cvector_i * tmp = (cvector_i * )vec ;
1520
1522
CVEC_FREE (tmp -> a );
1523
+ tmp -> a = NULL ;
1521
1524
tmp -> size = 0 ;
1522
1525
tmp -> capacity = 0 ;
1523
1526
}
@@ -1852,11 +1855,14 @@ void cvec_free_d_heap(void* vec)
1852
1855
CVEC_FREE (tmp );
1853
1856
}
1854
1857
1855
- /** Frees the internal array and sets size and capacity to 0 */
1858
+ /** Frees the internal array and zeros out the members to maintain a
1859
+ * consistent state */
1856
1860
void cvec_free_d (void * vec )
1857
1861
{
1858
1862
cvector_d * tmp = (cvector_d * )vec ;
1859
- CVEC_FREE (tmp -> a ); tmp -> size = 0 ;
1863
+ CVEC_FREE (tmp -> a );
1864
+ tmp -> a = NULL ;
1865
+ tmp -> size = 0 ;
1860
1866
tmp -> capacity = 0 ;
1861
1867
}
1862
1868
#endif
@@ -2354,7 +2360,8 @@ void cvec_free_str_heap(void* vec)
2354
2360
CVEC_FREE (tmp );
2355
2361
}
2356
2362
2357
- /** Frees the internal array and sets size and capacity to 0 */
2363
+ /** Frees the internal array and zeros out the members to maintain a
2364
+ * consistent state */
2358
2365
void cvec_free_str (void * vec )
2359
2366
{
2360
2367
cvec_sz i ;
@@ -2364,6 +2371,7 @@ void cvec_free_str(void* vec)
2364
2371
}
2365
2372
2366
2373
CVEC_FREE (tmp -> a );
2374
+ tmp -> a = NULL ;
2367
2375
tmp -> size = 0 ;
2368
2376
tmp -> capacity = 0 ;
2369
2377
}
@@ -3008,7 +3016,8 @@ void cvec_free_void_heap(void* vec)
3008
3016
CVEC_FREE (tmp );
3009
3017
}
3010
3018
3011
- /** Frees the internal array and sets size and capacity to 0 */
3019
+ /** Frees the internal array and sets it, size, and capacity to NULL/0 to
3020
+ * maintain a consistent state */
3012
3021
void cvec_free_void (void * vec )
3013
3022
{
3014
3023
cvec_sz i ;
@@ -3020,7 +3029,7 @@ void cvec_free_void(void* vec)
3020
3029
}
3021
3030
3022
3031
CVEC_FREE (tmp -> a );
3023
-
3032
+ tmp -> a = NULL ;
3024
3033
tmp -> size = 0 ;
3025
3034
tmp -> capacity = 0 ;
3026
3035
}
@@ -3185,7 +3194,7 @@ action and how it should behave, look at cvector_tests.c
3185
3194
\section LICENSE
3186
3195
CVector is licensed under the MIT License.
3187
3196
3188
- Copyright (c) 2011-2024 Robert Winkler
3197
+ Copyright (c) 2011-2025 Robert Winkler
3189
3198
3190
3199
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
3191
3200
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
0 commit comments