Lines Matching refs:bucket
599 vidmem_bucket *bucket;
604 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
605 printf("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, bucket->used ? "used" : "free");
606 if ( bucket->prev ) {
607 if ( bucket->base != bucket->prev->base+bucket->prev->size ) {
608 printf("Warning, corrupt bucket list! (prev)\n");
611 if ( bucket != &surfaces ) {
612 printf("Warning, corrupt bucket list! (!prev)\n");
615 if ( bucket->next ) {
616 if ( bucket->next->base != bucket->base+bucket->size ) {
617 printf("Warning, corrupt bucket list! (next)\n");
627 vidmem_bucket *bucket;
633 bucket = (vidmem_bucket *)SDL_malloc(sizeof(*bucket));
634 if ( bucket == NULL ) {
638 bucket->prev = &surfaces;
639 bucket->used = 0;
640 bucket->dirty = 0;
641 bucket->base = base;
642 bucket->size = size;
643 bucket->next = NULL;
645 bucket = NULL;
653 surfaces.next = bucket;
659 vidmem_bucket *bucket, *freeable;
661 bucket = surfaces.next;
662 while ( bucket ) {
663 freeable = bucket;
664 bucket = bucket->next;
682 vidmem_bucket *bucket;
688 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
689 bucket->dirty = 0;
695 vidmem_bucket *bucket;
711 fprintf(stderr, "Allocating bucket of %d bytes\n", size);
722 /* Search for an empty bucket big enough */
723 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
724 if ( ! bucket->used && (size <= bucket->size) ) {
728 if ( bucket == NULL ) {
734 /* Create a new bucket for left-over memory */
735 extra = (bucket->size - size);
740 fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
748 newbucket->prev = bucket;
750 newbucket->base = bucket->base+size;
752 newbucket->next = bucket->next;
753 if ( bucket->next ) {
754 bucket->next->prev = newbucket;
756 bucket->next = newbucket;
759 /* Set the current bucket values and return it! */
760 bucket->used = 1;
761 bucket->size = size;
762 bucket->dirty = 0;
764 fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
768 surface->pixels = bucket->base;
769 surface->hwdata = (struct private_hwdata *)bucket;
776 vidmem_bucket *bucket, *freeable;
785 /* Look for the bucket in the current list */
786 for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
787 if ( bucket == (vidmem_bucket *)surface->hwdata ) {
791 if ( bucket && bucket->used ) {
794 printf("Freeing bucket of %d bytes\n", bucket->size);
796 surfaces_memleft += bucket->size;
799 bucket->used = 0;
800 if ( bucket->next && ! bucket->next->used ) {
802 printf("Merging with next bucket, for %d total bytes\n", bucket->size+bucket->next->size);
804 freeable = bucket->next;
805 bucket->size += bucket->next->size;
806 bucket->next = bucket->next->next;
807 if ( bucket->next ) {
808 bucket->next->prev = bucket;
812 if ( bucket->prev && ! bucket->prev->used ) {
814 printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size);
816 freeable = bucket;
817 bucket->prev->size += bucket->size;
818 bucket->prev->next = bucket->next;
819 if ( bucket->next ) {
820 bucket->next->prev = bucket->prev;
1095 /* Clean up the memory bucket list */