Open Source Telephony
 help / color / mirror / Atom feed
From: Patrick Porlan <patrick.porlan@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] PPP: Switch ringbuffer.c to g_slice allocator
Date: Wed, 16 Mar 2011 10:24:23 +0100	[thread overview]
Message-ID: <1300267463-4980-1-git-send-email-patrick.porlan@linux.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1039 bytes --]

This should allow for more efficient handling of equally sized
buffers, in terms of alignment and recycling.
---
 gatchat/ringbuffer.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gatchat/ringbuffer.c b/gatchat/ringbuffer.c
index 27be3a8..775498c 100644
--- a/gatchat/ringbuffer.c
+++ b/gatchat/ringbuffer.c
@@ -51,11 +51,11 @@ struct ring_buffer *ring_buffer_new(unsigned int size)
 	if (real_size > MAX_SIZE)
 		return NULL;
 
-	buffer = g_try_new(struct ring_buffer, 1);
+	buffer = g_slice_new(struct ring_buffer);
 	if (buffer == NULL)
 		return NULL;
 
-	buffer->buffer = g_try_new(unsigned char, real_size);
+	buffer->buffer = g_slice_alloc(real_size);
 	if (buffer->buffer == NULL) {
 		g_free(buffer);
 		return NULL;
@@ -202,6 +202,6 @@ void ring_buffer_free(struct ring_buffer *buf)
 	if (buf == NULL)
 		return;
 
-	g_free(buf->buffer);
-	g_free(buf);
+	g_slice_free1(buf->size, buf->buffer);
+	g_slice_free1(sizeof(struct ring_buffer), buf);
 }
-- 
1.7.1


             reply	other threads:[~2011-03-16  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16  9:24 Patrick Porlan [this message]
2011-03-17  2:37 ` [PATCH] PPP: Switch ringbuffer.c to g_slice allocator Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1300267463-4980-1-git-send-email-patrick.porlan@linux.intel.com \
    --to=patrick.porlan@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox