# HG changeset patch # User reimar # Date 1280050260 0 # Node ID a0f828ae372ded3af532673493d87d64a50c60a7 # Parent 6be4d46328dd3320471bb976a78aad0a6c0f5871 Avoid useless malloc/frees diff -r 6be4d46328dd -r a0f828ae372d spudec.c --- a/spudec.c Sun Jul 25 09:22:37 2010 +0000 +++ b/spudec.c Sun Jul 25 09:31:00 2010 +0000 @@ -198,23 +198,14 @@ this->height = last_y - first_y +1; } else { this->height = 0; - this->image_size = 0; return; } // printf("new h %d new start %d (sz %d st %d)---\n\n", this->height, this->start_row, this->image_size, this->stride); - image = malloc(2 * this->stride * this->height); - if(image){ - this->image_size = this->stride * this->height; - aimage = image + this->image_size; - memcpy(image, this->image + this->stride * first_y, this->image_size); - memcpy(aimage, this->aimage + this->stride * first_y, this->image_size); - free(this->image); - this->image = image; - this->aimage = aimage; - } else { - mp_msg(MSGT_SPUDEC, MSGL_FATAL, "Fatal: update_spu: malloc requested %d bytes\n", 2 * this->stride * this->height); + if (first_y > 0) { + memmove(this->image, this->image + this->stride * first_y, this->stride * this->height); + memmove(this->aimage, this->aimage + this->stride * first_y, this->stride * this->height); } }