Quellcode durchsuchen

Remove lh_new's default hash and comparator.

This is a memory error for anything other than LHASH_OF(char), which
does not exist.

No code outside the library creates (or even queries) an LHASH, so we
can change this module freely.

Change-Id: Ifbc7a1c69a859e07650fcfaa067bdfc68d83fbbc
Reviewed-on: https://boringssl-review.googlesource.com/12978
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
David Benjamin vor 7 Jahren
committed by Adam Langley
Ursprung
Commit
55696cecde
3 geänderte Dateien mit 4 neuen und 14 gelöschten Zeilen
  1. +1
    -10
      crypto/lhash/lhash.c
  2. +2
    -1
      crypto/lhash/lhash_test.cc
  3. +1
    -3
      include/openssl/lhash.h

+ 1
- 10
crypto/lhash/lhash.c Datei anzeigen

@@ -74,9 +74,7 @@ static const size_t kMaxAverageChainLength = 2;
static const size_t kMinAverageChainLength = 1;

_LHASH *lh_new(lhash_hash_func hash, lhash_cmp_func comp) {
_LHASH *ret;

ret = OPENSSL_malloc(sizeof(_LHASH));
_LHASH *ret = OPENSSL_malloc(sizeof(_LHASH));
if (ret == NULL) {
return NULL;
}
@@ -91,14 +89,7 @@ _LHASH *lh_new(lhash_hash_func hash, lhash_cmp_func comp) {
OPENSSL_memset(ret->buckets, 0, sizeof(LHASH_ITEM *) * ret->num_buckets);

ret->comp = comp;
if (ret->comp == NULL) {
ret->comp = (lhash_cmp_func) strcmp;
}
ret->hash = hash;
if (ret->hash == NULL) {
ret->hash = (lhash_hash_func) lh_strhash;
}

return ret;
}



+ 2
- 1
crypto/lhash/lhash_test.cc Datei anzeigen

@@ -60,7 +60,8 @@ static const char *Lookup(
int main(int argc, char **argv) {
CRYPTO_library_init();

std::unique_ptr<_LHASH, FreeLHASH> lh(lh_new(NULL, NULL));
std::unique_ptr<_LHASH, FreeLHASH> lh(
lh_new((lhash_hash_func)lh_strhash, (lhash_cmp_func)strcmp));
if (!lh) {
return 1;
}


+ 1
- 3
include/openssl/lhash.h Datei anzeigen

@@ -144,9 +144,7 @@ typedef struct lhash_st {
lhash_hash_func hash;
} _LHASH;

/* lh_new returns a new, empty hash table or NULL on error. If |comp| is NULL,
* |strcmp| will be used. If |hash| is NULL, a generic hash function will be
* used. */
/* lh_new returns a new, empty hash table or NULL on error. */
OPENSSL_EXPORT _LHASH *lh_new(lhash_hash_func hash, lhash_cmp_func comp);

/* lh_free frees the hash table itself but none of the elements. See


Laden…
Abbrechen
Speichern