r3882 - trunk/birnet
- From: stw svn gnome org
- To: svn-commits-list gnome org
- Subject: r3882 - trunk/birnet
- Date: Sat, 16 Sep 2006 03:59:27 -0400 (EDT)
Author: stw
Date: 2006-09-16 03:59:25 -0400 (Sat, 16 Sep 2006)
New Revision: 3882
Modified:
trunk/birnet/ChangeLog
trunk/birnet/birnetutils.c
trunk/birnet/birnetutils.h
Log:
Sat Sep 16 09:20:49 2006 Stefan Westerfeld <stefan space twc de>
* birnetutils.[hc]: Added birnet_malloc_aligned(), which allocates
memory with an arbitary alignment. The caller is responsible for
for keeping track of and freeing the unaligned memory.
Modified: trunk/birnet/ChangeLog
===================================================================
--- trunk/birnet/ChangeLog 2006-09-11 23:42:06 UTC (rev 3881)
+++ trunk/birnet/ChangeLog 2006-09-16 07:59:25 UTC (rev 3882)
@@ -1,3 +1,9 @@
+Sat Sep 16 09:20:49 2006 Stefan Westerfeld <stefan space twc de>
+
+ * birnetutils.[hc]: Added birnet_malloc_aligned(), which allocates
+ memory with an arbitary alignment. The caller is responsible for
+ for keeping track of and freeing the unaligned memory.
+
Tue Sep 12 01:41:18 2006 Tim Janik <timj gtk org>
* birnetutilsxx.cc (rip_data): fix missing updates of 'last' pointer
Modified: trunk/birnet/birnetutils.c
===================================================================
--- trunk/birnet/birnetutils.c 2006-09-11 23:42:06 UTC (rev 3881)
+++ trunk/birnet/birnetutils.c 2006-09-16 07:59:25 UTC (rev 3882)
@@ -282,6 +282,21 @@
wmemset ((wchar_t*) mem, filler, length);
}
+/* --- memory utils --- */
+void*
+birnet_malloc_aligned (gsize total_size,
+ gsize alignment,
+ guint8 **free_pointer)
+{
+ *free_pointer = g_malloc (total_size + alignment - 1);
+
+ uint8 *aligned_mem = *free_pointer;
+ if ((ptrdiff_t) aligned_mem % alignment)
+ aligned_mem += alignment - (ptrdiff_t) free_pointer % alignment;
+
+ return aligned_mem;
+}
+
/* --- file testing --- */
static int
errno_check_file (const char *file_name,
Modified: trunk/birnet/birnetutils.h
===================================================================
--- trunk/birnet/birnetutils.h 2006-09-11 23:42:06 UTC (rev 3881)
+++ trunk/birnet/birnetutils.h 2006-09-16 07:59:25 UTC (rev 3882)
@@ -42,6 +42,10 @@
void birnet_memset4 (guint32 *mem,
guint32 filler,
guint length);
+/* --- memory utils --- */
+void* birnet_malloc_aligned (gsize total_size,
+ gsize alignment,
+ guint8 **free_pointer);
/* --- file testing --- */
bool birnet_file_check (const gchar *file, /* returns errno */
const gchar *mode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]