Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2002:
[Freeciv-Dev] (PR#2262) [Bug][Patch] Really call put_conv
Home

[Freeciv-Dev] (PR#2262) [Bug][Patch] Really call put_conv

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2262) [Bug][Patch] Really call put_conv
From: "Raimar Falke via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 28 Oct 2002 12:07:00 -0800
Reply-to: rt@xxxxxxxxxxxxxx


It turns out that the current dio_put_string implementation is simply:

  dio_put_memory(dout, value, strlen(value) + 1);

So the put_conv_callback isn't used at all.

We want to use dio_put_memory and not directly access the buffer. And
also we don't know the size of the converted string before. So the
callback has to allocate enough memory and tell the caller the
size. To not penalize the common case the function is now:

  if (put_conv_callback) {
    size_t buffer_length;
    unsigned char *buffer = put_conv_callback(value, &buffer_length);

    dio_put_memory(dout, buffer, buffer_length);
    free(buffer);
  } else {
    dio_put_memory(dout, value, strlen(value) + 1);
  }

So no malloc/free for every put_string.

        Raimar



[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2262) [Bug][Patch] Really call put_conv, Raimar Falke via RT <=