Author: matz Date: Tue Oct 30 22:42:51 2007 New Revision: 7720 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7720&view=rev Log: We can create blobs now. But can't yet store them into the file :) Modified: trunk/sat-solver/tools/attr_store.c trunk/sat-solver/tools/attr_store.h trunk/sat-solver/tools/attr_store_p.h Modified: trunk/sat-solver/tools/attr_store.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/attr_store.c?rev=7720&r1=7719&r2=7720&view=diff ============================================================================== --- trunk/sat-solver/tools/attr_store.c (original) +++ trunk/sat-solver/tools/attr_store.c Tue Oct 30 22:42:51 2007 @@ -16,20 +16,8 @@ #define NAME_WIDTH 12 #define TYPE_WIDTH (16-NAME_WIDTH) -typedef union -{ - struct { - unsigned short name : NAME_WIDTH; - unsigned short type : TYPE_WIDTH; - } nt; - unsigned short as_short; -} NameType; - -typedef struct -{ - NameType n; - char val[0]; -} __attribute__((packed)) NameVal; + +#define BLOB_BLOCK 65535 #define STRINGSPACE_BLOCK 1023 #define STRING_BLOCK 127 @@ -261,7 +249,7 @@ add_attr (s, entry, nv); } -void +static void add_attr_chunk (Attrstore *s, unsigned int entry, NameId name, unsigned int ofs, unsigned int len) { LongNV nv; @@ -273,6 +261,17 @@ } void +add_attr_blob (Attrstore *s, unsigned int entry, NameId name, const void *ptr, unsigned int len) +{ + if (((s->blob_next_free + BLOB_BLOCK) & ~BLOB_BLOCK) + != ((s->blob_next_free + len + BLOB_BLOCK) & ~BLOB_BLOCK)) + s->blob_store = xrealloc (s->blob_store, (s->blob_next_free + len + BLOB_BLOCK) & ~BLOB_BLOCK); + memcpy (s->blob_store + s->blob_next_free, ptr, len); + add_attr_chunk (s, entry, name, s->blob_next_free, len); + s->blob_next_free += len; +} + +void add_attr_string (Attrstore *s, unsigned int entry, NameId name, const char *val) { LongNV nv; @@ -344,6 +343,14 @@ } } +const void * +attr_retrieve_blob (Attrstore *s, unsigned int ofs, unsigned int len) +{ + if (!s->blob_store) + return 0; + return s->blob_store + ofs; +} + #define FLAT_ATTR_BLOCK 127 #define ABBR_BLOCK 127 #define FLAT_ABBR_BLOCK 127 @@ -827,7 +834,7 @@ } s->attr_next_free = read_u32 (fp); - s->flat_attrs = xmalloc (((s->attr_next_free + FLAT_ATTR_BLOCK) & ~(FLAT_ATTR_BLOCK + 1)) * sizeof (s->flat_attrs[0])); + s->flat_attrs = xmalloc (((s->attr_next_free + FLAT_ATTR_BLOCK) & ~FLAT_ATTR_BLOCK) * sizeof (s->flat_attrs[0])); if (fread (s->flat_attrs, s->attr_next_free, 1, fp) != 1) { perror ("read error"); @@ -835,7 +842,7 @@ } s->flat_abbr_next_free = read_u32 (fp); - s->flat_abbr = xmalloc (((s->flat_abbr_next_free + FLAT_ABBR_BLOCK) & ~(FLAT_ABBR_BLOCK + 1)) * sizeof (s->flat_abbr[0])); + s->flat_abbr = xmalloc (((s->flat_abbr_next_free + FLAT_ABBR_BLOCK) & ~FLAT_ABBR_BLOCK) * sizeof (s->flat_abbr[0])); if (fread (s->flat_abbr, s->flat_abbr_next_free * sizeof (s->flat_abbr[0]), 1, fp) != 1) { perror ("read error"); Modified: trunk/sat-solver/tools/attr_store.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/attr_store.h?rev=7720&r1=7719&r2=7720&view=diff ============================================================================== --- trunk/sat-solver/tools/attr_store.h (original) +++ trunk/sat-solver/tools/attr_store.h Tue Oct 30 22:42:51 2007 @@ -26,12 +26,13 @@ const char * localid2str(Attrstore *s, LocalId id); void add_attr_int (Attrstore *s, unsigned int entry, NameId name, unsigned int val); -void add_attr_chunk (Attrstore *s, unsigned int entry, NameId name, unsigned int ofs, unsigned int len); +void add_attr_blob (Attrstore *s, unsigned int entry, NameId name, const void *ptr, unsigned int len); void add_attr_string (Attrstore *s, unsigned int entry, NameId name, const char *val); void add_attr_id (Attrstore *s, unsigned int entry, NameId name, Id val); void add_attr_intlist_int (Attrstore *s, unsigned int entry, NameId name, int val); void add_attr_localids_id (Attrstore *s, unsigned int entry, NameId name, LocalId id); +const void * attr_retrieve_blob (Attrstore *s, unsigned int ofs, unsigned int len); #ifdef __cplusplus } #endif Modified: trunk/sat-solver/tools/attr_store_p.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/attr_store_p.h?rev=7720&r1=7719&r2=7720&view=diff ============================================================================== --- trunk/sat-solver/tools/attr_store_p.h (original) +++ trunk/sat-solver/tools/attr_store_p.h Tue Oct 30 22:42:51 2007 @@ -30,7 +30,8 @@ LongNV **attrs; unsigned int num_nameids; Id *nameids; - char *big_store; + char *blob_store; + unsigned int blob_next_free; Offset *strings; int nstrings; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org