tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tcc_relocate() and tcc_relocate_ex()


From: grischka
Subject: Re: [Tinycc-devel] tcc_relocate() and tcc_relocate_ex()
Date: Thu, 30 Aug 2012 22:30:29 +0200
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

Sean Conner wrote:
  I do not like this idea, and here's why:  it produces a function that does
two different things depending upon one parameter:

Count.  It is three different things.

        In both cases, it returns the number of bytes required to relocate
        the code.

No.

  I can't stand functions that do more than one thing for no real good
reason.

So being serious, you need
  - tcc_relocate
  - tcc_relocate_size
  - tcc_relocate_copy

which then are three functions that do almost the same thing.

Actually an earlier approach was to declare it like this:

    void *tcc_relocate(TCCState *s1, void *(*alloc_fn)(size_t));

So you could write
    tcc_relocate(TCCState *s1, NULL);
or
    mem = tcc_relocate(TCCState *s1, malloc);

I don't think this is one functions doing two entirely different things.

However one probably would want an user parameter like this

    void *tcc_relocate(TCCState *s1, void *(*alloc_fn)(size_t, void*), void 
*up);

which looks complicated and since you can't pass just malloc, also makes
things complicated.   So I decided for the two step approach.

--- grischka




reply via email to

[Prev in Thread] Current Thread [Next in Thread]