diff options
author | nanardon <nanardon@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2007-07-21 02:00:27 +0000 |
---|---|---|
committer | nanardon <nanardon@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2007-07-21 02:00:27 +0000 |
commit | e522e54059fa08222b5fa3eecf886955b71fb9bb (patch) | |
tree | b9bcc783ef6d98124077c486cc880536324c5b9d /RPM4/src | |
parent | 5bda9256094bd5e398c7b21dc189a0feab9a5559 (diff) | |
download | perl-RPM4-e522e54059fa08222b5fa3eecf886955b71fb9bb.tar perl-RPM4-e522e54059fa08222b5fa3eecf886955b71fb9bb.tar.gz perl-RPM4-e522e54059fa08222b5fa3eecf886955b71fb9bb.tar.bz2 perl-RPM4-e522e54059fa08222b5fa3eecf886955b71fb9bb.tar.xz perl-RPM4-e522e54059fa08222b5fa3eecf886955b71fb9bb.zip |
- string: fix test, then fix the function
git-svn-id: svn+ssh://haiku.zarb.org/home/projects/rpm4/svn/trunk@138 971eb68f-4bfb-0310-8326-d2484c010a4c
Diffstat (limited to 'RPM4/src')
-rw-r--r-- | RPM4/src/RPM4.xs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/RPM4/src/RPM4.xs b/RPM4/src/RPM4.xs index 257e563..f03fdc0 100644 --- a/RPM4/src/RPM4.xs +++ b/RPM4/src/RPM4.xs @@ -995,14 +995,19 @@ Header_string(h, no_header_magic = 0) PREINIT: char * string = NULL; int offset = 8; /* header magic length */ - void * ptr = NULL; + char * ptr = NULL; int hsize = 0; PPCODE: hsize = headerSizeof(h, no_header_magic ? HEADER_MAGIC_NO : HEADER_MAGIC_YES); string = headerUnload(h); - ptr = string + (no_header_magic ? offset : 0); - XPUSHs(sv_2mortal(newSVpv((char *)ptr, hsize))); + if (! no_header_magic) { + ptr = malloc(hsize); + memcpy(ptr, header_magic, 8); + memcpy(ptr + 8, string, hsize - 8); + } + XPUSHs(sv_2mortal(newSVpv(ptr ? ptr : string, hsize))); free(string); + free(ptr); int Header_removetag(h, sv_tag) |