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 * arena.c | 6 * arena.c |
7 * | 7 * |
8 * This contains the implementation of NSS's thread-safe arenas. | 8 * This contains the implementation of NSS's thread-safe arenas. |
9 */ | 9 */ |
10 | 10 |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 #ifdef ARENA_DESTRUCTOR_LIST | 697 #ifdef ARENA_DESTRUCTOR_LIST |
698 if( (struct arena_destructor_node *)NULL != arenaMark->prev_destructor ) { | 698 if( (struct arena_destructor_node *)NULL != arenaMark->prev_destructor ) { |
699 arenaMark->prev_destructor->next = (struct arena_destructor_node *)NULL; | 699 arenaMark->prev_destructor->next = (struct arena_destructor_node *)NULL; |
700 } | 700 } |
701 arena->last_destructor = arenaMark->prev_destructor; | 701 arena->last_destructor = arenaMark->prev_destructor; |
702 | 702 |
703 /* Note that the arena is locked at this time */ | 703 /* Note that the arena is locked at this time */ |
704 nss_arena_call_destructor_chain(arenaMark->next_destructor); | 704 nss_arena_call_destructor_chain(arenaMark->next_destructor); |
705 #endif /* ARENA_DESTRUCTOR_LIST */ | 705 #endif /* ARENA_DESTRUCTOR_LIST */ |
706 | 706 |
707 PR_ARENA_RELEASE(&arena->pool, inner_mark); | 707 PL_ARENA_RELEASE(&arena->pool, inner_mark); |
708 /* No error return */ | 708 /* No error return */ |
709 } | 709 } |
710 | 710 |
711 PR_Unlock(arena->lock); | 711 PR_Unlock(arena->lock); |
712 return PR_SUCCESS; | 712 return PR_SUCCESS; |
713 } | 713 } |
714 | 714 |
715 /* | 715 /* |
716 * nssArena_Release | 716 * nssArena_Release |
717 * | 717 * |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 nss_zalloc_arena_locked | 790 nss_zalloc_arena_locked |
791 ( | 791 ( |
792 NSSArena *arena, | 792 NSSArena *arena, |
793 PRUint32 size | 793 PRUint32 size |
794 ) | 794 ) |
795 { | 795 { |
796 void *p; | 796 void *p; |
797 void *rv; | 797 void *rv; |
798 struct pointer_header *h; | 798 struct pointer_header *h; |
799 PRUint32 my_size = size + sizeof(struct pointer_header); | 799 PRUint32 my_size = size + sizeof(struct pointer_header); |
800 PR_ARENA_ALLOCATE(p, &arena->pool, my_size); | 800 PL_ARENA_ALLOCATE(p, &arena->pool, my_size); |
801 if( (void *)NULL == p ) { | 801 if( (void *)NULL == p ) { |
802 nss_SetError(NSS_ERROR_NO_MEMORY); | 802 nss_SetError(NSS_ERROR_NO_MEMORY); |
803 return (void *)NULL; | 803 return (void *)NULL; |
804 } | 804 } |
805 /* | 805 /* |
806 * Do this before we unlock. This way if the user is using | 806 * Do this before we unlock. This way if the user is using |
807 * an arena in one thread while destroying it in another, he'll | 807 * an arena in one thread while destroying it in another, he'll |
808 * fault/FMR in his code, not ours. | 808 * fault/FMR in his code, not ours. |
809 */ | 809 */ |
810 h = (struct pointer_header *)p; | 810 h = (struct pointer_header *)p; |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 * if the user reallocs back up to something not greater than | 1172 * if the user reallocs back up to something not greater than |
1173 * the original size, then voila, there's the memory! This | 1173 * the original size, then voila, there's the memory! This |
1174 * way a thrash big/small/big/small doesn't burn up the arena. | 1174 * way a thrash big/small/big/small doesn't burn up the arena. |
1175 */ | 1175 */ |
1176 char *extra = &((char *)pointer)[ newSize ]; | 1176 char *extra = &((char *)pointer)[ newSize ]; |
1177 (void)nsslibc_memset(extra, 0, (h->size - newSize)); | 1177 (void)nsslibc_memset(extra, 0, (h->size - newSize)); |
1178 PR_Unlock(arena->lock); | 1178 PR_Unlock(arena->lock); |
1179 return pointer; | 1179 return pointer; |
1180 } | 1180 } |
1181 | 1181 |
1182 PR_ARENA_ALLOCATE(p, &arena->pool, my_newSize); | 1182 PL_ARENA_ALLOCATE(p, &arena->pool, my_newSize); |
1183 if( (void *)NULL == p ) { | 1183 if( (void *)NULL == p ) { |
1184 PR_Unlock(arena->lock); | 1184 PR_Unlock(arena->lock); |
1185 nss_SetError(NSS_ERROR_NO_MEMORY); | 1185 nss_SetError(NSS_ERROR_NO_MEMORY); |
1186 return (void *)NULL; | 1186 return (void *)NULL; |
1187 } | 1187 } |
1188 | 1188 |
1189 new_h = (struct pointer_header *)p; | 1189 new_h = (struct pointer_header *)p; |
1190 new_h->arena = arena; | 1190 new_h->arena = arena; |
1191 new_h->size = newSize; | 1191 new_h->size = newSize; |
1192 rv = (void *)((char *)new_h + sizeof(struct pointer_header)); | 1192 rv = (void *)((char *)new_h + sizeof(struct pointer_header)); |
(...skipping 12 matching lines...) Expand all Loading... |
1205 | 1205 |
1206 PRStatus | 1206 PRStatus |
1207 nssArena_Shutdown(void) | 1207 nssArena_Shutdown(void) |
1208 { | 1208 { |
1209 PRStatus rv = PR_SUCCESS; | 1209 PRStatus rv = PR_SUCCESS; |
1210 #ifdef DEBUG | 1210 #ifdef DEBUG |
1211 rv = nssPointerTracker_finalize(&arena_pointer_tracker); | 1211 rv = nssPointerTracker_finalize(&arena_pointer_tracker); |
1212 #endif | 1212 #endif |
1213 return rv; | 1213 return rv; |
1214 } | 1214 } |
OLD | NEW |