Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: mozilla/security/nss/lib/base/arena.c

Issue 10961060: Update NSS to NSS 3.14 Beta 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Add the NSS snapshot timestamp to README.chromium and nss-checkout.sh Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « README.chromium ('k') | mozilla/security/nss/lib/base/nssbase.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifdef DEBUG 5 #ifdef DEBUG
6 static const char CVS_ID[] = "@(#) $RCSfile: arena.c,v $ $Revision: 1.15 $ $Date : 2012/07/06 18:19:32 $"; 6 static const char CVS_ID[] = "@(#) $RCSfile: arena.c,v $ $Revision: 1.15 $ $Date : 2012/07/06 18:19:32 $";
7 #endif /* DEBUG */ 7 #endif /* DEBUG */
8 8
9 /* 9 /*
10 * arena.c 10 * arena.c
(...skipping 16 matching lines...) Expand all
27 27
28 /* 28 /*
29 * NSSArena 29 * NSSArena
30 * 30 *
31 * This is based on NSPR's arena code, but it is threadsafe. 31 * This is based on NSPR's arena code, but it is threadsafe.
32 * 32 *
33 * The public methods relating to this type are: 33 * The public methods relating to this type are:
34 * 34 *
35 * NSSArena_Create -- constructor 35 * NSSArena_Create -- constructor
36 * NSSArena_Destroy 36 * NSSArena_Destroy
37 * NSS_ZAlloc
38 * NSS_ZRealloc
39 * NSS_ZFreeIf
37 * 40 *
38 * The nonpublic methods relating to this type are: 41 * The nonpublic methods relating to this type are:
39 * 42 *
40 * nssArena_Create -- constructor 43 * nssArena_Create -- constructor
41 * nssArena_Destroy 44 * nssArena_Destroy
42 * nssArena_Mark 45 * nssArena_Mark
43 * nssArena_Release 46 * nssArena_Release
44 * nssArena_Unmark 47 * nssArena_Unmark
45 * 48 *
46 * nss_ZAlloc 49 * nss_ZAlloc
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 */ 813 */
811 h = (struct pointer_header *)p; 814 h = (struct pointer_header *)p;
812 h->arena = arena; 815 h->arena = arena;
813 h->size = size; 816 h->size = size;
814 rv = (void *)((char *)h + sizeof(struct pointer_header)); 817 rv = (void *)((char *)h + sizeof(struct pointer_header));
815 (void)nsslibc_memset(rv, 0, size); 818 (void)nsslibc_memset(rv, 0, size);
816 return rv; 819 return rv;
817 } 820 }
818 821
819 /* 822 /*
823 * NSS_ZAlloc
824 *
825 * This routine allocates and zeroes a section of memory of the
826 * size, and returns to the caller a pointer to that memory. If
827 * the optional arena argument is non-null, the memory will be
828 * obtained from that arena; otherwise, the memory will be obtained
829 * from the heap. This routine may return NULL upon error, in
830 * which case it will have set an error upon the error stack. The
831 * value specified for size may be zero; in which case a valid
832 * zero-length block of memory will be allocated. This block may
833 * be expanded by calling NSS_ZRealloc.
834 *
835 * The error may be one of the following values:
836 * NSS_ERROR_INVALID_ARENA
837 * NSS_ERROR_NO_MEMORY
838 * NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
839 *
840 * Return value:
841 * NULL upon error
842 * A pointer to the new segment of zeroed memory
843 */
844
845 NSS_IMPLEMENT void *
846 NSS_ZAlloc
847 (
848 NSSArena *arenaOpt,
849 PRUint32 size
850 )
851 {
852 return nss_ZAlloc(arenaOpt, size);
853 }
854
855 /*
820 * nss_ZAlloc 856 * nss_ZAlloc
821 * 857 *
822 * This routine allocates and zeroes a section of memory of the 858 * This routine allocates and zeroes a section of memory of the
823 * size, and returns to the caller a pointer to that memory. If 859 * size, and returns to the caller a pointer to that memory. If
824 * the optional arena argument is non-null, the memory will be 860 * the optional arena argument is non-null, the memory will be
825 * obtained from that arena; otherwise, the memory will be obtained 861 * obtained from that arena; otherwise, the memory will be obtained
826 * from the heap. This routine may return NULL upon error, in 862 * from the heap. This routine may return NULL upon error, in
827 * which case it will have set an error upon the error stack. The 863 * which case it will have set an error upon the error stack. The
828 * value specified for size may be zero; in which case a valid 864 * value specified for size may be zero; in which case a valid
829 * zero-length block of memory will be allocated. This block may 865 * zero-length block of memory will be allocated. This block may
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 932
897 rv = nss_zalloc_arena_locked(arenaOpt, size); 933 rv = nss_zalloc_arena_locked(arenaOpt, size);
898 934
899 PR_Unlock(arenaOpt->lock); 935 PR_Unlock(arenaOpt->lock);
900 return rv; 936 return rv;
901 } 937 }
902 /*NOTREACHED*/ 938 /*NOTREACHED*/
903 } 939 }
904 940
905 /* 941 /*
942 * NSS_ZFreeIf
943 *
944 * If the specified pointer is non-null, then the region of memory
945 * to which it points -- which must have been allocated with
946 * NSS_ZAlloc -- will be zeroed and released. This routine
947 * returns a PRStatus value; if successful, it will return PR_SUCCESS.
948 * If unsuccessful, it will set an error on the error stack and return
949 * PR_FAILURE.
950 *
951 * The error may be one of the following values:
952 * NSS_ERROR_INVALID_POINTER
953 *
954 * Return value:
955 * PR_SUCCESS
956 * PR_FAILURE
957 */
958 NSS_IMPLEMENT PRStatus
959 NSS_ZFreeIf
960 (
961 void *pointer
962 )
963 {
964 return nss_ZFreeIf(pointer);
965 }
966
967 /*
906 * nss_ZFreeIf 968 * nss_ZFreeIf
907 * 969 *
908 * If the specified pointer is non-null, then the region of memory 970 * If the specified pointer is non-null, then the region of memory
909 * to which it points -- which must have been allocated with 971 * to which it points -- which must have been allocated with
910 * nss_ZAlloc -- will be zeroed and released. This routine 972 * nss_ZAlloc -- will be zeroed and released. This routine
911 * returns a PRStatus value; if successful, it will return PR_SUCCESS. 973 * returns a PRStatus value; if successful, it will return PR_SUCCESS.
912 * If unsuccessful, it will set an error on the error stack and return 974 * If unsuccessful, it will set an error on the error stack and return
913 * PR_FAILURE. 975 * PR_FAILURE.
914 * 976 *
915 * The error may be one of the following values: 977 * The error may be one of the following values:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 1023
962 /* No way to "free" it within an NSPR arena. */ 1024 /* No way to "free" it within an NSPR arena. */
963 1025
964 PR_Unlock(h->arena->lock); 1026 PR_Unlock(h->arena->lock);
965 return PR_SUCCESS; 1027 return PR_SUCCESS;
966 } 1028 }
967 /*NOTREACHED*/ 1029 /*NOTREACHED*/
968 } 1030 }
969 1031
970 /* 1032 /*
1033 * NSS_ZRealloc
1034 *
1035 * This routine reallocates a block of memory obtained by calling
1036 * nss_ZAlloc or nss_ZRealloc. The portion of memory
1037 * between the new and old sizes -- which is either being newly
1038 * obtained or released -- is in either case zeroed. This routine
1039 * may return NULL upon failure, in which case it will have placed
1040 * an error on the error stack.
1041 *
1042 * The error may be one of the following values:
1043 * NSS_ERROR_INVALID_POINTER
1044 * NSS_ERROR_NO_MEMORY
1045 * NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
1046 *
1047 * Return value:
1048 * NULL upon error
1049 * A pointer to the replacement segment of memory
1050 */
1051
1052 NSS_EXTERN void *
1053 NSS_ZRealloc
1054 (
1055 void *pointer,
1056 PRUint32 newSize
1057 )
1058 {
1059 return nss_ZRealloc(pointer, newSize);
1060 }
1061
1062 /*
971 * nss_ZRealloc 1063 * nss_ZRealloc
972 * 1064 *
973 * This routine reallocates a block of memory obtained by calling 1065 * This routine reallocates a block of memory obtained by calling
974 * nss_ZAlloc or nss_ZRealloc. The portion of memory 1066 * nss_ZAlloc or nss_ZRealloc. The portion of memory
975 * between the new and old sizes -- which is either being newly 1067 * between the new and old sizes -- which is either being newly
976 * obtained or released -- is in either case zeroed. This routine 1068 * obtained or released -- is in either case zeroed. This routine
977 * may return NULL upon failure, in which case it will have placed 1069 * may return NULL upon failure, in which case it will have placed
978 * an error on the error stack. 1070 * an error on the error stack.
979 * 1071 *
980 * The error may be one of the following values: 1072 * The error may be one of the following values:
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1209
1118 PRStatus 1210 PRStatus
1119 nssArena_Shutdown(void) 1211 nssArena_Shutdown(void)
1120 { 1212 {
1121 PRStatus rv = PR_SUCCESS; 1213 PRStatus rv = PR_SUCCESS;
1122 #ifdef DEBUG 1214 #ifdef DEBUG
1123 rv = nssPointerTracker_finalize(&arena_pointer_tracker); 1215 rv = nssPointerTracker_finalize(&arena_pointer_tracker);
1124 #endif 1216 #endif
1125 return rv; 1217 return rv;
1126 } 1218 }
OLDNEW
« no previous file with comments | « README.chromium ('k') | mozilla/security/nss/lib/base/nssbase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698