diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-08-25 18:55:07 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-08-25 18:55:07 +0000 |
commit | dd3394742b3e2e01f403b1c1b41ed39273b2212e (patch) | |
tree | 5fed86738b0d518989679f3194f896fc9fcebbe2 /nscd/hstcache.c | |
parent | 9b0cdd693e7f54fd35fd58931b940efe6ccb88cd (diff) | |
download | glibc-dd3394742b3e2e01f403b1c1b41ed39273b2212e.tar glibc-dd3394742b3e2e01f403b1c1b41ed39273b2212e.tar.gz glibc-dd3394742b3e2e01f403b1c1b41ed39273b2212e.tar.bz2 glibc-dd3394742b3e2e01f403b1c1b41ed39273b2212e.zip |
Updated to fedora-glibc-20070825T1839
Diffstat (limited to 'nscd/hstcache.c')
-rw-r--r-- | nscd/hstcache.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/nscd/hstcache.c b/nscd/hstcache.c index 3c9a17fee8..54222a3408 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -196,7 +196,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, /* Determine the number of addresses. */ h_addr_list_cnt = 0; - for (cnt = 0; hst->h_addr_list[cnt]; ++cnt) + while (hst->h_addr_list[h_addr_list_cnt] != NULL) ++h_addr_list_cnt; if (h_addr_list_cnt == 0) @@ -221,7 +221,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, the current cache handling cannot handle and it is more than questionable whether it is worthwhile complicating the cache handling just for handling such a special case. */ - if (he == NULL && hst->h_addr_list[1] == NULL) + if (he == NULL && h_addr_list_cnt == 1) { dataset = (struct dataset *) mempool_alloc (db, total + req->key_len); @@ -298,25 +298,31 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, /* The data has not changed. We will just bump the timeout value. Note that the new record has been allocated on the stack and need not be freed. */ + assert (h_addr_list_cnt == 1); dh->timeout = dataset->head.timeout; ++dh->nreloads; } else { - /* We have to create a new record. Just allocate - appropriate memory and copy it. */ - struct dataset *newp - = (struct dataset *) mempool_alloc (db, total + req->key_len); - if (newp != NULL) + if (h_addr_list_cnt == 1) { - /* Adjust pointers into the memory block. */ - addresses = (char *) newp + (addresses - (char *) dataset); - aliases = (char *) newp + (aliases - (char *) dataset); - assert (key_copy != NULL); - key_copy = (char *) newp + (key_copy - (char *) dataset); - - dataset = memcpy (newp, dataset, total + req->key_len); - alloca_used = false; + /* We have to create a new record. Just allocate + appropriate memory and copy it. */ + struct dataset *newp + = (struct dataset *) mempool_alloc (db, + total + req->key_len); + if (newp != NULL) + { + /* Adjust pointers into the memory block. */ + addresses = (char *) newp + (addresses + - (char *) dataset); + aliases = (char *) newp + (aliases - (char *) dataset); + assert (key_copy != NULL); + key_copy = (char *) newp + (key_copy - (char *) dataset); + + dataset = memcpy (newp, dataset, total + req->key_len); + alloca_used = false; + } } /* Mark the old record as obsolete. */ |