Peter M a écrit :

I have tried to make the changes and I have next problems:

- I need size of the block to "free":

I tried to save it in the “user”

This cannot be done easily, since FreeType doesn't always store the size of
allocated blocks. You'll need to handle this in your allocator (e.g. allocate a slightly larger block, store the size and a magic number at the start, then return
the address of the first free bytes in it. Do the reverse in 'free')

I'm sad to say that your code is totally bogus. The value stored in "memory->user" is going to change on each allocation, and will certainly never correspond to the
block size you want to free when the CPU reaches ft_free.


- When I use "MEM_redefine" in don’t get a pointer returned:

So I redefine the block and return the same pointer.

What does this MEM_redefine function does then ? Is is a macro that changes the
value of the 'block' parameter.

Why are you returning 'memory' instead of 'block' by the way ? This looks insane.

When I debug the code I see code cycles every 53 steps. Alloc trays to

Allocate the same size and returns the same pointer.

Can someone help?

this might be explained by the buggy behaviour described previously. There are great chances that you're essentially trashing your memory manager's internal data structures.

Hope this helps,

- David Turner
- The FreeType Project (www.freetype.org)


======================================================

FT_CALLBACK_DEF( void* )

ft_alloc( FT_Memory memory,

long size )

{

FT_UNUSED( memory );

memory->user = (void*)size;

return (void* )MEM_alloc( SDRAM, size, 2 );

//return malloc( size );

}

======================================================

FT_CALLBACK_DEF( void* )

ft_realloc( FT_Memory memory,

long cur_size,

long new_size,

void* block )

{

FT_UNUSED( memory );

FT_UNUSED( cur_size );

memory->user = (void*)new_size;

MEM_redefine( SDRAM, block, new_size );

return (memory);

//return realloc( block, new_size );

}

======================================================

FT_CALLBACK_DEF( void )

ft_free( FT_Memory memory,

void* block )

{

FT_UNUSED( memory );

(void* ) MEM_free( SDRAM, block, (int)memory->user );

// free( block );

}

Thanks

Peter M

------------------------------------------------------------------------

_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel

***********************************************************************************
Information contained in this email message is confidential and may be 
privileged, and is intended only for use of the individual or entity named 
above. If the reader of this message is not the intended recipient, or the 
employee or agent responsible to deliver it to the intended recipient, you are 
hereby notified that any dissemination, distribution or copying of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the [EMAIL PROTECTED] and destroy the 
original message.
***********************************************************************************


_______________________________________________
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to