All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] Add hash table support as base for new environment code
Date: Sun, 12 Sep 2010 21:16:51 +0200	[thread overview]
Message-ID: <20100912191651.598B615242D@gemini.denx.de> (raw)
In-Reply-To: <1279395948-25864-4-git-send-email-wd@denx.de>

Dear Wolfgang Denk,

In message <1279395948-25864-4-git-send-email-wd@denx.de> you wrote:
> This implementation is based on code from uClibc-0.9.30.3 but was
> modified and extended for use within U-Boot.
> 
> Major modifications and extensions:
> 
> * hsearch() [modified / extended]:
>   - While the standard version does not make any assumptions about
>     the type of the stored data objects at all, this implementation
>     works with NUL terminated strings only.
>   - Instead of storing just pointers to the original objects, we
>     create local copies so the caller does not need to care about the
>     data any more.
>   - The standard implementation does not provide a way to update an
>     existing entry.  This version will create a new entry or update an
>     existing one when both "action == ENTER" and "item.data != NULL".
>   - hsearch_r(): Instead of returning 1 on success, we return the
>     index into the internal hash table, which is also guaranteed to be
>     positive.  This allows us direct access to the found hash table
>     slot for example for functions like hdelete().
> * hdelete() [added]:
>   - The standard implementation of hsearch(3) does not provide any way
>     to delete any entries from the hash table.  We extend the code to
>     do that.
> * hexport() [added]:
>   - Export the data stored in the hash table in linearized form:
>     Entries are exported as "name=value" strings, separated by an
>     arbitrary (non-NUL, of course) separator character. This allows to
>     use this function both when formatting the U-Boot environment for
>     external storage (using '\0' as separator), but also when using it
>     for the "printenv" command to print all variables, simply by using
>     as '\n" as separator. This can also be used for new features like
>     exporting the environment data as text file, including the option
>     for later re-import.
>   - The entries in the result list will be sorted by ascending key
>     values.
> * himport() [added]:
>   - Import linearized data into hash table.  This is the inverse
>     function to hexport(): it takes a linear list of "name=value"
>     pairs and creates hash table entries from it.
>   - Entries without "value", i. e. consisting of only "name" or
>     "name=", will cause this entry to be deleted from the hash table.
>   - The "flag" argument can be used to control the behaviour: when
>     the H_NOCLEAR bit is set, then an existing hash table will kept,
>     i. e. new data will be added to an existing hash table;
>     otherwise, old data will be discarded and a new hash table will
>     be created.
>   - The separator character for the "name=value" pairs can be
>     selected, so we both support importing from externally stored
>     environment data (separated by NUL characters) and from plain text
>     files (entries separated by newline characters).
>   - To allow for nicely formatted text input, leading white space
>     (sequences of SPACE and TAB chars) is ignored, and entries
>     starting (after removal of any leading white space) with a '#'
>     character are considered comments and ignored.
>   - NOTE: this means that a variable name cannot start with a '#'
>     character.
>   - When using a non-NUL separator character, backslash is used as
>     escape character in the value part, allowing for example fo
>     multi-line values.
>   - In theory, arbitrary separator characters can be used, but only
>     '\0' and '\n' have really been tested.
> 
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> ---
>  include/search.h |  106 ++++++++
>  lib/Makefile     |    1 +
>  lib/hashtable.c  |  721 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 828 insertions(+), 0 deletions(-)
>  create mode 100644 include/search.h
>  create mode 100644 lib/hashtable.c

Applied to "next" branch.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It seems intuitively obvious to me, which  means  that  it  might  be
wrong.                                                 -- Chris Torek

  reply	other threads:[~2010-09-12 19:16 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-17 19:45 [U-Boot] [PATCH 0/5] New environment code Wolfgang Denk
2010-07-17 19:45 ` [U-Boot] [PATCH 1/5] Add basic errno support Wolfgang Denk
2010-07-17 21:17   ` Mike Frysinger
2010-07-17 21:34     ` Wolfgang Denk
2010-07-18 12:51     ` Jerry Van Baren
2010-07-18 13:03       ` Wolfgang Denk
2010-09-12 19:16   ` Wolfgang Denk
2010-07-17 19:45 ` [U-Boot] [PATCH 2/5] Add qsort - add support for sorting data arrays Wolfgang Denk
2010-09-12 19:16   ` Wolfgang Denk
2010-07-17 19:45 ` [U-Boot] [PATCH 3/5] Add hash table support as base for new environment code Wolfgang Denk
2010-09-12 19:16   ` Wolfgang Denk [this message]
2010-12-08  9:44   ` Mike Frysinger
2010-12-08 10:02     ` Wolfgang Denk
2010-12-08 10:52       ` Mike Frysinger
2010-07-17 19:45 ` [U-Boot] [PATCH 4/5] Remove support for CONFIG_HAS_UID and "forceenv" command Wolfgang Denk
2010-07-17 22:12   ` Sergey Kubushyn
2010-09-12 19:18   ` Wolfgang Denk
2010-07-17 19:45 ` [U-Boot] [PATCH 5/5] New implementation for internal handling of environment variables Wolfgang Denk
2010-07-17 22:48   ` [U-Boot] [PATCH] new env: fix off-by-one error in setenv command Wolfgang Denk
2010-07-20  0:38   ` [U-Boot] [PATCH 5/5] New implementation for internal handling of environment variables Kim Phillips
2010-07-20  9:40     ` Wolfgang Denk
2010-07-20 18:36       ` Kim Phillips
2010-07-20 19:01         ` Wolfgang Denk
2010-07-20 20:09           ` Wolfgang Denk
     [not found]             ` <1279658019.5685.125.camel@thunk>
2010-07-20 20:35               ` Wolfgang Denk
2010-07-20 21:08             ` Kim Phillips
2010-07-20 21:43               ` Wolfgang Denk
2010-07-20 22:00                 ` Kim Phillips
2010-07-25 21:45                   ` Wolfgang Denk
2010-07-26 23:18                     ` Kim Phillips
2010-07-20 19:11         ` Wolfgang Denk
2010-07-26 14:52   ` Matthias Fuchs
2010-07-28 21:17     ` Wolfgang Denk
2010-07-29  9:16       ` Matthias Fuchs
2010-08-03 22:48         ` Wolfgang Denk
2010-09-12 19:19   ` Wolfgang Denk
2010-12-30  1:53   ` [U-Boot] env_flash.c:saveenv() broken when env is smaller than a sector Mike Frysinger
2010-12-30  2:39     ` Mike Frysinger
2011-01-17 20:23       ` Wolfgang Denk
2010-07-17 19:49 ` [U-Boot] [PATCH 0/5] New environment code Wolfgang Denk
2010-07-17 20:56 ` Reinhard Meyer
2010-07-17 21:28   ` Mike Frysinger
2010-07-17 21:41     ` Wolfgang Denk
2010-07-18  2:18       ` Mike Frysinger
2010-07-17 21:31   ` Wolfgang Denk
2010-07-17 21:55 ` Wolfgang Denk
2010-07-18  5:32   ` Reinhard Meyer
2010-07-18 10:26     ` Wolfgang Denk
2010-10-20  8:08 ` Mike Frysinger
2010-10-20  8:19   ` Wolfgang Denk
2010-12-08  9:56 ` Mike Frysinger
2010-12-08 10:04   ` Wolfgang Denk
2010-12-08 10:19     ` Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100912191651.598B615242D@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.