Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(196)

Side by Side Diff: src/core/SkMemory_stdlib.cpp

Issue 96099: Whitespace fix: remove whitespace from the end of lines.
Patch Set: Created 16 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | src/core/SkPackBits.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* libs/corecg/SkMemory_stdlib.cpp 1 /* libs/corecg/SkMemory_stdlib.cpp
2 ** 2 **
3 ** Copyright 2006, The Android Open Source Project 3 ** Copyright 2006, The Android Open Source Project
4 ** 4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License"); 5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License. 6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at 7 ** You may obtain a copy of the License at
8 ** 8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0 9 ** http://www.apache.org/licenses/LICENSE-2.0
10 ** 10 **
11 ** Unless required by applicable law or agreed to in writing, software 11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS, 12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and 14 ** See the License for the specific language governing permissions and
15 ** limitations under the License. 15 ** limitations under the License.
16 */ 16 */
17 17
18 #include "SkTypes.h" 18 #include "SkTypes.h"
19 #include <stdio.h> 19 #include <stdio.h>
20 #include <stdlib.h> 20 #include <stdlib.h>
21 21
22 #ifdef SK_DEBUG 22 #ifdef SK_DEBUG
23 #define SK_TAG_BLOCKS 23 #define SK_TAG_BLOCKS
24 // #define SK_TRACK_ALLOC // enable to see a printf for every alloc/free 24 // #define SK_TRACK_ALLOC // enable to see a printf for every alloc/free
(...skipping 26 matching lines...) Expand all
51 SkBlockHeader* fNext; 51 SkBlockHeader* fNext;
52 #ifdef SK_CHECK_TAGS 52 #ifdef SK_CHECK_TAGS
53 SkBlockHeader** fTop; // set to verify in debugger that block was alloc'd / freed with same gHeader 53 SkBlockHeader** fTop; // set to verify in debugger that block was alloc'd / freed with same gHeader
54 SkBlockHeader* fPrevious; // set to see in debugger previous block when corr uption happens 54 SkBlockHeader* fPrevious; // set to see in debugger previous block when corr uption happens
55 #endif 55 #endif
56 size_t fSize; 56 size_t fSize;
57 char fHeader[sizeof(kBlockHeaderTag)]; 57 char fHeader[sizeof(kBlockHeaderTag)];
58 // data goes here. The offset to this point must be a multiple of 8 58 // data goes here. The offset to this point must be a multiple of 8
59 char fTrailer[sizeof(kBlockTrailerTag)]; 59 char fTrailer[sizeof(kBlockTrailerTag)];
60 60
61 void* add(size_t realSize) 61 void* add(size_t realSize)
62 { 62 {
63 SkAutoMutexAcquire ac(get_block_mutex()); 63 SkAutoMutexAcquire ac(get_block_mutex());
64 InMutexValidate(); 64 InMutexValidate();
65 fNext = gHeader; 65 fNext = gHeader;
66 #ifdef SK_CHECK_TAGS 66 #ifdef SK_CHECK_TAGS
67 fTop = &gHeader; 67 fTop = &gHeader;
68 fPrevious = NULL; 68 fPrevious = NULL;
69 if (fNext != NULL) 69 if (fNext != NULL)
70 fNext->fPrevious = this; 70 fNext->fPrevious = this;
71 #endif 71 #endif
72 gHeader = this; 72 gHeader = this;
73 fSize = realSize; 73 fSize = realSize;
74 memcpy(fHeader, kBlockHeaderTag, sizeof(kBlockHeaderTag)); 74 memcpy(fHeader, kBlockHeaderTag, sizeof(kBlockHeaderTag));
75 void* result = fTrailer; 75 void* result = fTrailer;
76 void* trailer = (char*)result + realSize; 76 void* trailer = (char*)result + realSize;
77 memcpy(trailer, kBlockTrailerTag, sizeof(kBlockTrailerTag)); 77 memcpy(trailer, kBlockTrailerTag, sizeof(kBlockTrailerTag));
78 return result; 78 return result;
79 } 79 }
80 80
81 static void Dump() 81 static void Dump()
82 { 82 {
83 SkAutoMutexAcquire ac(get_block_mutex()); 83 SkAutoMutexAcquire ac(get_block_mutex());
84 InMutexValidate(); 84 InMutexValidate();
85 SkBlockHeader* header = gHeader; 85 SkBlockHeader* header = gHeader;
86 int count = 0; 86 int count = 0;
87 size_t size = 0; 87 size_t size = 0;
88 while (header != NULL) { 88 while (header != NULL) {
89 char scratch[256]; 89 char scratch[256];
90 char* pos = scratch; 90 char* pos = scratch;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 *findPtr = fNext; 129 *findPtr = fNext;
130 break; 130 break;
131 } 131 }
132 findPtr = &find->fNext; 132 findPtr = &find->fNext;
133 } while (true); 133 } while (true);
134 InMutexValidate(); 134 InMutexValidate();
135 SkASSERT(memcmp(fHeader, kBlockHeaderTag, sizeof(kBlockHeaderTag)) == 0) ; 135 SkASSERT(memcmp(fHeader, kBlockHeaderTag, sizeof(kBlockHeaderTag)) == 0) ;
136 const char* trailer = fTrailer + fSize; 136 const char* trailer = fTrailer + fSize;
137 SkASSERT(memcmp(trailer, kBlockTrailerTag, sizeof(kBlockTrailerTag)) == 0); 137 SkASSERT(memcmp(trailer, kBlockTrailerTag, sizeof(kBlockTrailerTag)) == 0);
138 } 138 }
139 139
140 static void Validate() 140 static void Validate()
141 { 141 {
142 SkAutoMutexAcquire ac(get_block_mutex()); 142 SkAutoMutexAcquire ac(get_block_mutex());
143 InMutexValidate(); 143 InMutexValidate();
144 } 144 }
145 145
146 private: 146 private:
147 static void InMutexValidate() 147 static void InMutexValidate()
148 { 148 {
149 SkBlockHeader* header = gHeader; 149 SkBlockHeader* header = gHeader;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (addr != NULL) { 194 if (addr != NULL) {
195 SkBlockHeader* header = (SkBlockHeader*) 195 SkBlockHeader* header = (SkBlockHeader*)
196 ((char*)addr - SK_OFFSETOF(SkBlockHeader, fTrailer)); 196 ((char*)addr - SK_OFFSETOF(SkBlockHeader, fTrailer));
197 header->remove(); 197 header->remove();
198 #ifdef SK_TRACK_ALLOC 198 #ifdef SK_TRACK_ALLOC
199 printf("sk_realloc_throw %p oldSize=%zd\n", addr, header->fSize); 199 printf("sk_realloc_throw %p oldSize=%zd\n", addr, header->fSize);
200 #endif 200 #endif
201 addr = header; 201 addr = header;
202 } 202 }
203 size_t realSize = size; 203 size_t realSize = size;
204 if (size) 204 if (size)
205 size += sizeof(SkBlockHeader); 205 size += sizeof(SkBlockHeader);
206 #endif 206 #endif
207 207
208 void* p = realloc(addr, size); 208 void* p = realloc(addr, size);
209 if (size == 0) 209 if (size == 0)
210 { 210 {
211 ValidateHeap(); 211 ValidateHeap();
212 return p; 212 return p;
213 } 213 }
214 214
(...skipping 12 matching lines...) Expand all
227 ValidateHeap(); 227 ValidateHeap();
228 return p; 228 return p;
229 } 229 }
230 230
231 void sk_free(void* p) 231 void sk_free(void* p)
232 { 232 {
233 if (p) 233 if (p)
234 { 234 {
235 ValidateHeap(); 235 ValidateHeap();
236 #ifdef SK_TAG_BLOCKS 236 #ifdef SK_TAG_BLOCKS
237 SkBlockHeader* header = (SkBlockHeader*) 237 SkBlockHeader* header = (SkBlockHeader*)
238 ((char*)p - SK_OFFSETOF(SkBlockHeader, fTrailer)); 238 ((char*)p - SK_OFFSETOF(SkBlockHeader, fTrailer));
239 header->remove(); 239 header->remove();
240 #ifdef SK_TRACK_ALLOC 240 #ifdef SK_TRACK_ALLOC
241 printf("sk_free %p size=%zd\n", p, header->fSize); 241 printf("sk_free %p size=%zd\n", p, header->fSize);
242 #endif 242 #endif
243 size_t size = header->fSize + sizeof(SkBlockHeader); 243 size_t size = header->fSize + sizeof(SkBlockHeader);
244 memset(header, kDeleteFill, size); 244 memset(header, kDeleteFill, size);
245 p = header; 245 p = header;
246 #endif 246 #endif
247 ValidateHeap(); 247 ValidateHeap();
248 free(p); 248 free(p);
249 ValidateHeap(); 249 ValidateHeap();
250 } 250 }
251 } 251 }
252 252
253 void* sk_malloc_flags(size_t size, unsigned flags) 253 void* sk_malloc_flags(size_t size, unsigned flags)
254 { 254 {
255 ValidateHeap(); 255 ValidateHeap();
256 #ifdef SK_TAG_BLOCKS 256 #ifdef SK_TAG_BLOCKS
257 size_t realSize = size; 257 size_t realSize = size;
258 size += sizeof(SkBlockHeader); 258 size += sizeof(SkBlockHeader);
259 #endif 259 #endif
260 260
261 void* p = malloc(size); 261 void* p = malloc(size);
262 if (p == NULL) 262 if (p == NULL)
263 { 263 {
264 if (flags & SK_MALLOC_THROW) 264 if (flags & SK_MALLOC_THROW)
265 sk_throw(); 265 sk_throw();
266 } 266 }
267 #ifdef SK_TAG_BLOCKS 267 #ifdef SK_TAG_BLOCKS
268 else 268 else
269 { 269 {
270 SkBlockHeader* header = (SkBlockHeader*) p; 270 SkBlockHeader* header = (SkBlockHeader*) p;
271 p = header->add(realSize); 271 p = header->add(realSize);
272 memset(p, kByteFill, realSize); 272 memset(p, kByteFill, realSize);
273 #ifdef SK_TRACK_ALLOC 273 #ifdef SK_TRACK_ALLOC
274 printf("sk_malloc_flags %p size=%zd\n", p, realSize); 274 printf("sk_malloc_flags %p size=%zd\n", p, realSize);
275 #endif 275 #endif
276 } 276 }
277 #endif 277 #endif
278 ValidateHeap(); 278 ValidateHeap();
279 return p; 279 return p;
280 } 280 }
281 281
OLDNEW
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | src/core/SkPackBits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b