Changeset 11674 for trunk/psLib/src/sys/psMemory.c
- Timestamp:
- Feb 6, 2007, 3:15:50 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.c
r11672 r11674 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.9 3$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-02-07 0 0:36:02$12 * @version $Revision: 1.94 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-02-07 01:15:49 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 355 355 } 356 356 357 int p_psMemCheckCorruption(FILE *output, 358 bool abort_on_error, 359 const char *file, 357 int p_psMemCheckCorruption(const char *file, 360 358 unsigned int lineno, 361 const char *func) 359 const char *func, 360 FILE *output, 361 bool abort_on_error) 362 362 { 363 363 // get exclusive access to the memBlock list to avoid it changing on us … … 385 385 } 386 386 387 387 388 /* 388 389 * Set whether allocated memory is persistent … … 400 401 } 401 402 403 402 404 /* 403 405 * Actually allocate memory 404 406 */ 405 void *p_psAlloc(size_t size, 406 const char *file, 407 void *p_psAlloc(const char *file, 407 408 unsigned int lineno, 408 const char *func) 409 const char *func, 410 size_t size) 409 411 { 410 412 … … 490 492 } 491 493 492 void *p_psRealloc(void *ptr, 493 size_t size, 494 const char *file, 494 495 void *p_psRealloc(const char *file, 495 496 unsigned int lineno, 496 const char *func) 497 const char *func, 498 void *ptr, 499 size_t size) 497 500 { 498 501 if (ptr == NULL) { 499 return p_psAlloc( size, file, lineno, func);502 return p_psAlloc(file, lineno, func, size); 500 503 } 501 504 … … 565 568 * Check for memory leaks. 566 569 */ 567 int p_psMemCheckLeaks(psMemId id0, 570 int p_psMemCheckLeaks(const char *file, 571 unsigned int lineno, 572 const char *func, 573 psMemId id0, 568 574 psMemBlock ***array, 569 575 FILE * fd, 570 bool persistence, 571 const char *file, 572 unsigned int lineno, 573 const char *func) 576 bool persistence) 574 577 { 575 578 psS32 nleak = 0; … … 579 582 // make sure that the memblock list is free of corruption before we crawl 580 583 // the list 581 p_psMemCheckCorruption(f d, true, file, lineno, func);584 p_psMemCheckCorruption(file, lineno, func, fd, true); 582 585 583 586 MUTEX_LOCK(&memBlockListMutex); … … 675 678 } 676 679 680 677 681 /* 678 682 * Reference counting APIs 679 683 */ 680 681 // return refCounter 682 psReferenceCount p_psMemGetRefCounter(void *ptr, 683 const char *file, 684 psReferenceCount p_psMemGetRefCounter(const char *file, 684 685 unsigned int lineno, 685 const char *func) 686 const char *func, 687 void *ptr) 686 688 { 687 689 if (ptr == NULL) { … … 696 698 } 697 699 700 698 701 // increment and return refCounter 699 void *p_psMemIncrRefCounter(void *ptr, 700 const char *file, 702 void *p_psMemIncrRefCounter(const char *file, 701 703 unsigned int lineno, 702 const char *func) 704 const char *func, 705 void *ptr) 703 706 { 704 707 if (ptr == NULL) { … … 721 724 return ptr; 722 725 } 726 723 727 724 728 #if 0 … … 755 759 #endif 756 760 761 757 762 // decrement and return refCounter 758 void *p_psMemDecrRefCounter(void * ptr, 759 const char *file, 763 void *p_psMemDecrRefCounter(const char *file, 760 764 unsigned int lineno, 761 const char *func) 765 const char *func, 766 void * ptr) 762 767 { 763 768 if (ptr == NULL) { … … 823 828 } 824 829 825 void p_psMemSetDeallocator(void *ptr, 826 psFreeFunc freeFunc, 827 const char *file, 830 831 void p_psMemSetDeallocator(const char *file, 828 832 unsigned int lineno, 829 const char *func) 833 const char *func, 834 void *ptr, 835 psFreeFunc freeFunc) 830 836 { 831 837 if (ptr == NULL) { … … 840 846 } 841 847 842 psFreeFunc p_psMemGetDeallocator(void *ptr, 843 const char *file,848 849 psFreeFunc p_psMemGetDeallocator(const char *file, 844 850 unsigned int lineno, 845 const char *func) 851 const char *func, 852 void *ptr) 846 853 { 847 854 if (ptr == NULL) { … … 856 863 } 857 864 865 858 866 bool psMemSetThreadSafety(bool safe) 859 867 { … … 868 876 } 869 877 878 870 879 bool psMemGetThreadSafety(void) 871 880 { … … 879 888 } 880 889 881 bool p_psMemGetPersistent(void *ptr, 882 const char *file,890 891 bool p_psMemGetPersistent(const char *file, 883 892 unsigned int lineno, 884 const char *func) 893 const char *func, 894 void *ptr) 885 895 { 886 896 if (ptr == NULL) { … … 895 905 } 896 906 897 void p_psMemSetPersistent(void *ptr, 898 bool value, 899 const char *file, 907 908 void p_psMemSetPersistent(const char *file, 900 909 unsigned int lineno, 901 const char *func) 910 const char *func, 911 void *ptr, 912 bool value) 902 913 { 903 914 if (ptr == NULL) { … … 912 923 } 913 924 914 /************************************************************************************************************/ 915 /* 916 * Return the total amount of memory owned by psLib; if non-NULL also provide a breakdown 917 * into recyclable, allocated, and allocated-and-persistent 925 926 /******************************************************************************/ 927 /* 928 * Return the total amount of memory owned by psLib; if non-NULL also provide a 929 * breakdown into recyclable, allocated, and allocated-and-persistent 918 930 * 919 * It would be simple enough to fix this code to return an array of structs to describe920 * the insides of the allocator rather than the printf used here.931 * It would be simple enough to fix this code to return an array of structs to 932 * describe the insides of the allocator rather than the printf used here. 921 933 */ 922 934 size_t psMemStats(const bool print, // print details as they're found?
Note:
See TracChangeset
for help on using the changeset viewer.
