diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2009-01-20 14:15:24 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2009-01-20 14:15:24 +0200 |
commit | 05f5c353242d0dfa70ef49918c73c92dec923920 (patch) | |
tree | 3fa779fa28e5486267cef8e09b9fd696fbc9eba5 /lib/header.c | |
parent | a46dd884ec348b3ce23b9f53302e6626a90ae631 (diff) | |
download | rpm-05f5c353242d0dfa70ef49918c73c92dec923920.tar.gz rpm-05f5c353242d0dfa70ef49918c73c92dec923920.tar.bz2 rpm-05f5c353242d0dfa70ef49918c73c92dec923920.zip |
Add headerGet() flag to request argv-style NULL-terminated string arrays
- easy to do and some places would like the data this way so why not...
- also add corresponding rpmtd flag so caller can verify he got what
was requested
Diffstat (limited to 'lib/header.c')
-rw-r--r-- | lib/header.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/header.c b/lib/header.c index 0b6ed3e55..96a6f1c5f 100644 --- a/lib/header.c +++ b/lib/header.c @@ -1144,8 +1144,10 @@ static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags) /* ALLOC overrides MINMEM */ int allocMem = flags & HEADERGET_ALLOC; int minMem = allocMem ? 0 : flags & HEADERGET_MINMEM; + int argvArray = (flags & HEADERGET_ARGV) ? 1 : 0; assert(td != NULL); + td->flags = RPMTD_IMMUTABLE; switch (entry->info.type) { case RPM_BIN_TYPE: /* @@ -1198,7 +1200,7 @@ static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags) case RPM_STRING_ARRAY_TYPE: case RPM_I18NSTRING_TYPE: { const char ** ptrEntry; - int tableSize = count * sizeof(char *); + int tableSize = (count + argvArray) * sizeof(char *); char * t; int i; @@ -1218,6 +1220,10 @@ static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags) t = strchr(t, 0); t++; } + if (argvArray) { + *ptrEntry = NULL; + td->flags |= RPMTD_ARGV; + } } break; case RPM_CHAR_TYPE: case RPM_INT8_TYPE: @@ -1240,7 +1246,6 @@ static int copyTdEntry(const indexEntry entry, rpmtd td, headerGetFlags flags) td->type = entry->info.type; td->count = count; - td->flags = RPMTD_IMMUTABLE; if (td->data && entry->data != td->data) { td->flags |= RPMTD_ALLOCED; } |