Differences From Artifact [708e72ca3d]:
- File src/OFObject.m — part of check-in [ce1c7fe940] at 2012-03-21 14:47:14 on branch trunk — OFObject: Use owner as a sentinel for pre_mem. (user: js, size: 24982) [annotate] [blame] [check-ins using] [more...]
To Artifact [51c24d6468]:
- File
src/OFObject.m
— part of check-in
[f7576a66ce]
at
2012-06-06 13:47:52
on branch trunk
— Slightly change the memory management API.
Also fix a bug where OFBigDataArray would waste memory. (user: js, size: 25006) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
799 800 801 802 803 804 805 | PRE_IVAR->lastMem->next = preMem; PRE_IVAR->lastMem = preMem; return (char*)pointer + PRE_MEM_ALIGN; } | | | | | | | 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | PRE_IVAR->lastMem->next = preMem; PRE_IVAR->lastMem = preMem; return (char*)pointer + PRE_MEM_ALIGN; } - (void*)allocMemoryWithItemSize: (size_t)itemSize count: (size_t)count { if (itemSize == 0 || count == 0) return NULL; if (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exceptionWithClass: isa]; return [self allocMemoryWithSize: itemSize * count]; } - (void*)resizeMemory: (void*)pointer toSize: (size_t)size { void *new; struct pre_mem *preMem; |
︙ | ︙ | |||
851 852 853 854 855 856 857 | PRE_IVAR->lastMem = preMem; } return (char*)new + PRE_MEM_ALIGN; } - (void*)resizeMemory: (void*)pointer | | | | | | | | | 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | PRE_IVAR->lastMem = preMem; } return (char*)new + PRE_MEM_ALIGN; } - (void*)resizeMemory: (void*)pointer itemSize: (size_t)itemSize count: (size_t)count { if (pointer == NULL) return [self allocMemoryWithItemSize: itemSize count: count]; if (itemSize == 0 || count == 0) { [self freeMemory: pointer]; return NULL; } if (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exceptionWithClass: isa]; return [self resizeMemory: pointer toSize: itemSize * count]; } - (void)freeMemory: (void*)pointer { if (pointer == NULL) return; |
︙ | ︙ | |||
1028 1029 1030 1031 1032 1033 1034 | */ + (void*)allocMemoryWithSize: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } | | | | | | 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 | */ + (void*)allocMemoryWithSize: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } + (void*)allocMemoryWithItemSize: (size_t)itemSize count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } + (void*)resizeMemory: (void*)pointer toSize: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } + (void*)resizeMemory: (void*)pointer itemSize: (size_t)itemSize count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } + (void)freeMemory: (void*)pointer { |
︙ | ︙ |