The following commit has been merged in the master branch:
commit 7e7236f7e19f1b4e238359d887756e7044328891
Author: Guillem Jover <guil...@debian.org>
Date:   Tue May 3 10:28:26 2011 +0200

    libdpkg: Expand buffer_copy_TYPE macro instances
    
    This makes the code easier to debug, as it will be able to track
    correct code lines, it also allows to more easily see the code
    duplication explicitly, and makes the code slightly more clear as
    it's using the real structure member and type names.

diff --git a/lib/dpkg/buffer.c b/lib/dpkg/buffer.c
index 0a6ab19..0ac9e46 100644
--- a/lib/dpkg/buffer.c
+++ b/lib/dpkg/buffer.c
@@ -204,28 +204,46 @@ buffer_copy(struct buffer_data *read_data, struct 
buffer_data *write_data,
        return totalread;
 }
 
-#define buffer_copy_TYPE(name, type1, name1, type2, name2) \
-off_t \
-buffer_copy_##name(type1 n1, int typeIn, \
-                   type2 n2, int typeOut, \
-                   off_t limit, const char *desc, ...) \
-{ \
-       va_list args; \
-       struct buffer_data read_data = { .arg.name1 = n1, .type = typeIn }; \
-       struct buffer_data write_data = { .arg.name2 = n2, .type = typeOut }; \
-       struct varbuf v = VARBUF_INIT; \
-       off_t ret; \
-\
-       va_start(args, desc); \
-       varbuf_vprintf(&v, desc, args); \
-       va_end(args); \
-\
-       ret = buffer_copy(&read_data, &write_data, limit, v.buf); \
-\
-       varbuf_destroy(&v); \
-\
-       return ret; \
+off_t
+buffer_copy_IntInt(int Iin, int Tin,
+                   int Iout, int Tout,
+                   off_t limit, const char *desc, ...)
+{
+       va_list args;
+       struct buffer_data read_data = { .type = Tin, .arg.i = Iin };
+       struct buffer_data write_data = { .type = Tout, .arg.i = Iout };
+       struct varbuf v = VARBUF_INIT;
+       off_t ret;
+
+       va_start(args, desc);
+       varbuf_vprintf(&v, desc, args);
+       va_end(args);
+
+       ret = buffer_copy(&read_data, &write_data, limit, v.buf);
+
+       varbuf_destroy(&v);
+
+       return ret;
 }
 
-buffer_copy_TYPE(IntInt, int, i, int, i);
-buffer_copy_TYPE(IntPtr, int, i, void *, ptr);
+off_t
+buffer_copy_IntPtr(int Iin, int Tin,
+                   void *Pout, int Tout,
+                   off_t limit, const char *desc, ...)
+{
+       va_list args;
+       struct buffer_data read_data = { .type = Tin, .arg.i = Iin };
+       struct buffer_data write_data = { .type = Tout, .arg.ptr = Pout };
+       struct varbuf v = VARBUF_INIT;
+       off_t ret;
+
+       va_start(args, desc);
+       varbuf_vprintf(&v, desc, args);
+       va_end(args);
+
+       ret = buffer_copy(&read_data, &write_data, limit, v.buf);
+
+       varbuf_destroy(&v);
+
+       return ret;
+}

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to