Commit 36c9bed
authored
FIX: Handling Access token with class level variables and removing static defination (#323)
### Work Item / Issue Reference
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#40420](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/40420)
-------------------------------------------------------------------
### Summary
This pull request refactors the way temporary buffers are managed for
setting connection attributes in the `Connection` class, improving
memory safety and simplifying buffer handling. Instead of using static
vectors to store temporary string and binary data, the code now uses
member variables to hold these buffers directly within each `Connection`
instance.
**Buffer Management Refactor:**
* Removed static vectors (`wstr_buffers`, `buffers`) for storing
temporary wide string and binary buffers, eliminating the need for
manual buffer growth management and cleanup.
[[1]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL211-L212)
[[2]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL221-R219)
[[3]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL269-R262)
* Added member variables `wstrStringBuffer` and `strBytesBuffer` to the
`Connection` class for managing temporary buffers per connection
instance, improving encapsulation and memory safety.
* Updated all relevant buffer usage in `setAttribute` to use these new
member variables, replacing references to static buffers with instance
variables.
[[1]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL248-R237)
[[2]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL221-R219)
[[3]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL269-R262)
**Code Simplification:**
* Removed unnecessary static buffer and related logic, such as buffer
size limits and periodic cleanup, resulting in cleaner and more
maintainable code.
[[1]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL191)
[[2]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL221-R219)
[[3]](diffhunk://#diff-eca696c13d997f510e5f9b16288ed1deb0ad132768c283eda1518f78edf9b6ecL269-R262)1 parent aae194c commit 36c9bed
2 files changed
+12
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | 191 | | |
193 | 192 | | |
194 | 193 | | |
| |||
208 | 207 | | |
209 | 208 | | |
210 | 209 | | |
211 | | - | |
212 | | - | |
213 | 210 | | |
214 | 211 | | |
215 | 212 | | |
| |||
218 | 215 | | |
219 | 216 | | |
220 | 217 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 218 | + | |
| 219 | + | |
231 | 220 | | |
232 | 221 | | |
233 | 222 | | |
234 | 223 | | |
235 | 224 | | |
236 | 225 | | |
237 | | - | |
238 | | - | |
| 226 | + | |
| 227 | + | |
239 | 228 | | |
240 | 229 | | |
241 | 230 | | |
| |||
245 | 234 | | |
246 | 235 | | |
247 | 236 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 237 | + | |
| 238 | + | |
251 | 239 | | |
252 | 240 | | |
253 | 241 | | |
| |||
266 | 254 | | |
267 | 255 | | |
268 | 256 | | |
269 | | - | |
270 | 257 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
284 | 262 | | |
285 | 263 | | |
286 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
0 commit comments