OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * Support routines for SECItem data structure. | 6 * Support routines for SECItem data structure. |
7 * | 7 * |
8 * $Id$ | 8 * $Id$ |
9 */ | 9 */ |
10 | 10 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 PORT_Free(result); | 353 PORT_Free(result); |
354 } | 354 } |
355 /* | 355 /* |
356 * If array is not NULL, the above has set array->data and | 356 * If array is not NULL, the above has set array->data and |
357 * array->len to 0. | 357 * array->len to 0. |
358 */ | 358 */ |
359 } | 359 } |
360 return(NULL); | 360 return(NULL); |
361 } | 361 } |
362 | 362 |
363 void secitem_FreeArray(SECItemArray *array, PRBool zero_items, PRBool freeit) | 363 static void |
| 364 secitem_FreeArray(SECItemArray *array, PRBool zero_items, PRBool freeit) |
364 { | 365 { |
365 unsigned int i; | 366 unsigned int i; |
366 | 367 |
367 if (!array || !array->len || !array->items) | 368 if (!array || !array->len || !array->items) |
368 return; | 369 return; |
369 | 370 |
370 for (i=0; i<array->len; ++i) { | 371 for (i=0; i<array->len; ++i) { |
371 SECItem *item = &array->items[i]; | 372 SECItem *item = &array->items[i]; |
372 | 373 |
373 if (item->data) { | 374 if (item->data) { |
374 if (zero_items) { | 375 if (zero_items) { |
375 SECITEM_ZfreeItem(item, PR_FALSE); | 376 SECITEM_ZfreeItem(item, PR_FALSE); |
376 } else { | 377 } else { |
377 SECITEM_FreeItem(item, PR_FALSE); | 378 SECITEM_FreeItem(item, PR_FALSE); |
378 } | 379 } |
379 } | 380 } |
380 } | 381 } |
| 382 PORT_Free(array->items); |
| 383 array->items = NULL; |
| 384 array->len = 0; |
381 | 385 |
382 if (freeit) | 386 if (freeit) |
383 PORT_Free(array); | 387 PORT_Free(array); |
384 } | 388 } |
385 | 389 |
386 void SECITEM_FreeArray(SECItemArray *array, PRBool freeit) | 390 void SECITEM_FreeArray(SECItemArray *array, PRBool freeit) |
387 { | 391 { |
388 secitem_FreeArray(array, PR_FALSE, freeit); | 392 secitem_FreeArray(array, PR_FALSE, freeit); |
389 } | 393 } |
390 | 394 |
(...skipping 19 matching lines...) Expand all Loading... |
410 SECStatus rv = SECITEM_CopyItem(arena, | 414 SECStatus rv = SECITEM_CopyItem(arena, |
411 &result->items[i], &from->items[i]); | 415 &result->items[i], &from->items[i]); |
412 if (rv != SECSuccess) { | 416 if (rv != SECSuccess) { |
413 SECITEM_ZfreeArray(result, PR_TRUE); | 417 SECITEM_ZfreeArray(result, PR_TRUE); |
414 return NULL; | 418 return NULL; |
415 } | 419 } |
416 } | 420 } |
417 | 421 |
418 return result; | 422 return result; |
419 } | 423 } |
OLD | NEW |