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 * pkix_pl_object.c | 5 * pkix_pl_object.c |
6 * | 6 * |
7 * Object Construction, Destruction and Callback Functions | 7 * Object Construction, Destruction and Callback Functions |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 */ | 364 */ |
365 static PKIX_Error * | 365 static PKIX_Error * |
366 pkix_pl_Object_Hashcode_Default( | 366 pkix_pl_Object_Hashcode_Default( |
367 PKIX_PL_Object *object, | 367 PKIX_PL_Object *object, |
368 PKIX_UInt32 *pValue, | 368 PKIX_UInt32 *pValue, |
369 void *plContext) | 369 void *plContext) |
370 { | 370 { |
371 PKIX_ENTER(OBJECT, "pkix_pl_Object_Hashcode_Default"); | 371 PKIX_ENTER(OBJECT, "pkix_pl_Object_Hashcode_Default"); |
372 PKIX_NULLCHECK_TWO(object, pValue); | 372 PKIX_NULLCHECK_TWO(object, pValue); |
373 | 373 |
374 *pValue = (PKIX_UInt32)object; | 374 *pValue = (PKIX_UInt32)((char *)object - (char *)NULL); |
375 | 375 |
376 PKIX_RETURN(OBJECT); | 376 PKIX_RETURN(OBJECT); |
377 } | 377 } |
378 | 378 |
379 /* | 379 /* |
380 * FUNCTION: pkix_pl_Object_RetrieveEqualsCallback | 380 * FUNCTION: pkix_pl_Object_RetrieveEqualsCallback |
381 * DESCRIPTION: | 381 * DESCRIPTION: |
382 * | 382 * |
383 * Retrieves Equals callback function of Object pointed to by "object and | 383 * Retrieves Equals callback function of Object pointed to by "object and |
384 * stores it at "pEqualsCallback". If the object's type is one of the system | 384 * stores it at "pEqualsCallback". If the object's type is one of the system |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 } | 593 } |
594 | 594 |
595 PKIX_OBJECT_DEBUG("\tShifting object pointer).\n"); | 595 PKIX_OBJECT_DEBUG("\tShifting object pointer).\n"); |
596 | 596 |
597 | 597 |
598 /* Return a pointer to the user data. Need to offset by object size */ | 598 /* Return a pointer to the user data. Need to offset by object size */ |
599 *pObject = object + 1; | 599 *pObject = object + 1; |
600 object = NULL; | 600 object = NULL; |
601 | 601 |
602 /* Atomically increment object counter */ | 602 /* Atomically increment object counter */ |
603 PR_ATOMIC_INCREMENT(&ctEntry->objCounter); | 603 PR_ATOMIC_INCREMENT((PRInt32*)&ctEntry->objCounter); |
604 | 604 |
605 cleanup: | 605 cleanup: |
606 | 606 |
607 PKIX_FREE(object); | 607 PKIX_FREE(object); |
608 | 608 |
609 PKIX_RETURN(OBJECT); | 609 PKIX_RETURN(OBJECT); |
610 } | 610 } |
611 | 611 |
612 /* | 612 /* |
613 * FUNCTION: PKIX_PL_Object_IsTypeRegistered (see comments in pkix_pl_system.h) | 613 * FUNCTION: PKIX_PL_Object_IsTypeRegistered (see comments in pkix_pl_system.h) |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 /* Call destructor on user data if necessary */ | 890 /* Call destructor on user data if necessary */ |
891 pkixErrorResult = destructor(object, plContext); | 891 pkixErrorResult = destructor(object, plContext); |
892 if (pkixErrorResult) { | 892 if (pkixErrorResult) { |
893 pkixErrorClass = PKIX_FATAL_ERROR; | 893 pkixErrorClass = PKIX_FATAL_ERROR; |
894 PKIX_DoAddError(stdVarsPtr, pkixErrorResult, plContext); | 894 PKIX_DoAddError(stdVarsPtr, pkixErrorResult, plContext); |
895 pkixErrorResult = NULL; | 895 pkixErrorResult = NULL; |
896 } | 896 } |
897 } | 897 } |
898 | 898 |
899 /* Atomically decrement object counter */ | 899 /* Atomically decrement object counter */ |
900 PR_ATOMIC_DECREMENT(&ctEntry->objCounter); | 900 PR_ATOMIC_DECREMENT((PRInt32*)&ctEntry->objCounter); |
901 | 901 |
902 /* pkix_pl_Object_Destroy assumes the lock is held */ | 902 /* pkix_pl_Object_Destroy assumes the lock is held */ |
903 /* It will call unlock and destroy the object */ | 903 /* It will call unlock and destroy the object */ |
904 pkixErrorResult = pkix_pl_Object_Destroy(object, plContext); | 904 pkixErrorResult = pkix_pl_Object_Destroy(object, plContext); |
905 goto cleanup; | 905 goto cleanup; |
906 } | 906 } |
907 | 907 |
908 if (refCount < 0) { | 908 if (refCount < 0) { |
909 PKIX_ERROR_ALLOC_ERROR(); | 909 PKIX_ERROR_ALLOC_ERROR(); |
910 } | 910 } |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 /* Shift pointer from user data to object header */ | 1431 /* Shift pointer from user data to object header */ |
1432 PKIX_CHECK(pkix_pl_Object_GetHeader(object, &objectHeader, plContext), | 1432 PKIX_CHECK(pkix_pl_Object_GetHeader(object, &objectHeader, plContext), |
1433 PKIX_RECEIVEDCORRUPTEDOBJECTARGUMENT); | 1433 PKIX_RECEIVEDCORRUPTEDOBJECTARGUMENT); |
1434 | 1434 |
1435 *pType = objectHeader->type; | 1435 *pType = objectHeader->type; |
1436 | 1436 |
1437 cleanup: | 1437 cleanup: |
1438 | 1438 |
1439 PKIX_RETURN(OBJECT); | 1439 PKIX_RETURN(OBJECT); |
1440 } | 1440 } |
OLD | NEW |