OLD | NEW |
1 /* Copyright (c) 2009, Google Inc. | 1 /* Copyright (c) 2009, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 MallocExtension_MarkThreadIdle(); | 119 MallocExtension_MarkThreadIdle(); |
120 MallocExtension_MarkThreadBusy(); | 120 MallocExtension_MarkThreadBusy(); |
121 MallocExtension_ReleaseToSystem(1); | 121 MallocExtension_ReleaseToSystem(1); |
122 MallocExtension_ReleaseFreeMemory(); | 122 MallocExtension_ReleaseFreeMemory(); |
123 if (MallocExtension_GetEstimatedAllocatedSize(10) < 10) { | 123 if (MallocExtension_GetEstimatedAllocatedSize(10) < 10) { |
124 FAIL("GetEstimatedAllocatedSize returned a bad value (too small)"); | 124 FAIL("GetEstimatedAllocatedSize returned a bad value (too small)"); |
125 } | 125 } |
126 if (MallocExtension_GetAllocatedSize(x) < 10) { | 126 if (MallocExtension_GetAllocatedSize(x) < 10) { |
127 FAIL("GetEstimatedAllocatedSize returned a bad value (too small)"); | 127 FAIL("GetEstimatedAllocatedSize returned a bad value (too small)"); |
128 } | 128 } |
| 129 if (MallocExtension_GetOwnership(x) != MallocExtension_kOwned) { |
| 130 FAIL("DidAllocatePtr returned a bad value (kNotOwned)"); |
| 131 } |
| 132 /* TODO(csilvers): this relies on undocumented behavior that |
| 133 GetOwnership works on stack-allocated variables. Use a better test. */ |
| 134 if (MallocExtension_GetOwnership(hist) != MallocExtension_kNotOwned) { |
| 135 FAIL("DidAllocatePtr returned a bad value (kOwned)"); |
| 136 } |
129 | 137 |
130 free(x); | 138 free(x); |
131 } | 139 } |
132 | 140 |
133 int main(int argc, char** argv) { | 141 int main(int argc, char** argv) { |
134 TestMallocHook(); | 142 TestMallocHook(); |
135 TestMallocExtension(); | 143 TestMallocExtension(); |
136 | 144 |
137 printf("PASS\n"); | 145 printf("PASS\n"); |
138 return 0; | 146 return 0; |
139 } | 147 } |
OLD | NEW |