Lines Matching refs:bucket
1192 vidmem_bucket *bucket;
1197 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
1198 printf("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, bucket->used ? "used" : "free");
1199 if ( bucket->prev ) {
1200 if ( bucket->base != bucket->prev->base+bucket->prev->size ) {
1201 printf("Warning, corrupt bucket list! (prev)\n");
1204 if ( bucket != &surfaces ) {
1205 printf("Warning, corrupt bucket list! (!prev)\n");
1208 if ( bucket->next ) {
1209 if ( bucket->next->base != bucket->base+bucket->size ) {
1210 printf("Warning, corrupt bucket list! (next)\n");
1220 vidmem_bucket *bucket;
1226 bucket = (vidmem_bucket *)SDL_malloc(sizeof(*bucket));
1227 if ( bucket == NULL ) {
1231 bucket->prev = &surfaces;
1232 bucket->used = 0;
1233 bucket->dirty = 0;
1234 bucket->base = base;
1235 bucket->size = size;
1236 bucket->next = NULL;
1238 bucket = NULL;
1246 surfaces.next = bucket;
1252 vidmem_bucket *bucket, *freeable;
1254 bucket = surfaces.next;
1255 while ( bucket ) {
1256 freeable = bucket;
1257 bucket = bucket->next;
1265 vidmem_bucket *bucket;
1281 fprintf(stderr, "Allocating bucket of %d bytes\n", size);
1290 /* Search for an empty bucket big enough */
1291 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
1292 if ( ! bucket->used && (size <= bucket->size) ) {
1296 if ( bucket == NULL ) {
1301 /* Create a new bucket for left-over memory */
1302 extra = (bucket->size - size);
1307 fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
1314 newbucket->prev = bucket;
1316 newbucket->base = bucket->base+size;
1318 newbucket->next = bucket->next;
1319 if ( bucket->next ) {
1320 bucket->next->prev = newbucket;
1322 bucket->next = newbucket;
1325 /* Set the current bucket values and return it! */
1326 bucket->used = 1;
1327 bucket->size = size;
1328 bucket->dirty = 0;
1330 fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
1334 surface->pixels = bucket->base;
1335 surface->hwdata = (struct private_hwdata *)bucket;
1340 vidmem_bucket *bucket, *freeable;
1342 /* Look for the bucket in the current list */
1343 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
1344 if ( bucket == (vidmem_bucket *)surface->hwdata ) {
1348 if ( bucket && bucket->used ) {
1351 printf("Freeing bucket of %d bytes\n", bucket->size);
1353 surfaces_memleft += bucket->size;
1356 bucket->used = 0;
1357 if ( bucket->next && ! bucket->next->used ) {
1359 printf("Merging with next bucket, for %d total bytes\n", bucket->size+bucket->next->size);
1361 freeable = bucket->next;
1362 bucket->size += bucket->next->size;
1363 bucket->next = bucket->next->next;
1364 if ( bucket->next ) {
1365 bucket->next->prev = bucket;
1369 if ( bucket->prev && ! bucket->prev->used ) {
1371 printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size);
1373 freeable = bucket;
1374 bucket->prev->size += bucket->size;
1375 bucket->prev->next = bucket->next;
1376 if ( bucket->next ) {
1377 bucket->next->prev = bucket->prev;
1955 /* Clean up the memory bucket list */