Subversion Repositories freemyipod

Rev

Rev 568 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 568 Rev 625
Line 899... Line 899...
899
** - a request that cannot be satisfied will leave the original buffer
899
** - a request that cannot be satisfied will leave the original buffer
900
**   untouched
900
**   untouched
901
** - an extended buffer size will leave the newly-allocated area with
901
** - an extended buffer size will leave the newly-allocated area with
902
**   contents undefined
902
**   contents undefined
903
*/
903
*/
904
void* tlsf_realloc(tlsf_pool tlsf, void* ptr, size_t size)
904
void* tlsf_realign(tlsf_pool tlsf, void* ptr, size_t align, size_t size)
905
{
905
{
906
	pool_t* pool = tlsf_cast(pool_t*, tlsf);
906
	pool_t* pool = tlsf_cast(pool_t*, tlsf);
907
	void* p = 0;
907
	void* p = 0;
908
 
908
 
909
	/* Zero-size requests are treated as free. */
909
	/* Zero-size requests are treated as free. */
Line 929... Line 929...
929
		** If the next block is used, or when combined with the current
929
		** If the next block is used, or when combined with the current
930
		** block, does not offer enough space, we must reallocate and copy.
930
		** block, does not offer enough space, we must reallocate and copy.
931
		*/
931
		*/
932
		if (adjust > cursize && (!block_is_free(next) || adjust > combined))
932
		if (adjust > cursize && (!block_is_free(next) || adjust > combined))
933
		{
933
		{
-
 
934
            if (align > 4) p = tlsf_memalign(tlsf, align, size);
934
			p = tlsf_malloc(tlsf, size);
935
            else p = tlsf_malloc(tlsf, size);
935
			if (p)
936
			if (p)
936
			{
937
			{
937
				const size_t minsize = tlsf_min(cursize, size);
938
				const size_t minsize = tlsf_min(cursize, size);
938
				memcpy(p, ptr, minsize);
939
				memcpy(p, ptr, minsize);
939
				tlsf_free(tlsf, ptr);
940
				tlsf_free(tlsf, ptr);
Line 954... Line 955...
954
		}
955
		}
955
	}
956
	}
956
 
957
 
957
	return p;
958
	return p;
958
}
959
}
-
 
960
 
-
 
961
void* tlsf_realloc(tlsf_pool tlsf, void* ptr, size_t size)
-
 
962
{
-
 
963
    return tlsf_realign(tlsf, ptr, 4, size);
-
 
964
}