diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-07 16:58:44 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-07 16:58:44 +0000 |
commit | 45778d82d7d094e40c59108da0b97e99f6caa77e (patch) | |
tree | d8ce22a5833854d073fbaece7ce26a1b5dd47bdd /src/namestore/gnunet-service-namestore.c | |
parent | 3b85ce75b48e259ef0926a3b02203d4e9b0fea35 (diff) | |
download | gnunet-45778d82d7d094e40c59108da0b97e99f6caa77e.tar.gz gnunet-45778d82d7d094e40c59108da0b97e99f6caa77e.zip |
- fix
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 67c7e6e57..723e81fe8 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -800,11 +800,10 @@ handle_record_remove_it (void *cls, | |||
800 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 800 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
801 | { | 801 | { |
802 | struct RemoveRecordContext *rrc = cls; | 802 | struct RemoveRecordContext *rrc = cls; |
803 | unsigned int rd_count_new = rd_count -1; | ||
804 | struct GNUNET_NAMESTORE_RecordData rd_new[rd_count_new]; | ||
805 | unsigned int c; | 803 | unsigned int c; |
806 | int res; | 804 | int res; |
807 | int found = GNUNET_NO; | 805 | int found; |
806 | unsigned int rd_count_new; | ||
808 | 807 | ||
809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name `%s 'currently has %u records\n", name, rd_count); | 808 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name `%s 'currently has %u records\n", name, rd_count); |
810 | 809 | ||
@@ -816,7 +815,7 @@ handle_record_remove_it (void *cls, | |||
816 | } | 815 | } |
817 | 816 | ||
818 | /* Find record to remove */ | 817 | /* Find record to remove */ |
819 | unsigned int c2 = 0; | 818 | found = GNUNET_SYSERR; |
820 | for (c = 0; c < rd_count; c++) | 819 | for (c = 0; c < rd_count; c++) |
821 | { | 820 | { |
822 | if ((rd[c].expiration.abs_value == rrc->rd->expiration.abs_value) && | 821 | if ((rd[c].expiration.abs_value == rrc->rd->expiration.abs_value) && |
@@ -826,21 +825,31 @@ handle_record_remove_it (void *cls, | |||
826 | (0 == memcmp (rd[c].data, rrc->rd->data, rrc->rd->data_size))) | 825 | (0 == memcmp (rd[c].data, rrc->rd->data, rrc->rd->data_size))) |
827 | { | 826 | { |
828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found record to remove!\n", rd_count); | 827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found record to remove!\n", rd_count); |
829 | found = GNUNET_YES; | 828 | found = c; |
830 | continue; | 829 | break; |
831 | } | 830 | } |
832 | else | ||
833 | { | ||
834 | rd_new[c2] = rd[c]; | ||
835 | c2 ++; | ||
836 | } | ||
837 | } | 831 | } |
838 | if ((c2 != rd_count_new) || (found == GNUNET_NO)) | 832 | if (GNUNET_SYSERR == found) |
839 | { | 833 | { |
840 | /* Could not find record to remove */ | 834 | /* Could not find record to remove */ |
841 | rrc->op_res = 2; | 835 | rrc->op_res = 2; |
842 | return; | 836 | return; |
843 | } | 837 | } |
838 | |||
839 | rd_count_new = rd_count -1; | ||
840 | struct GNUNET_NAMESTORE_RecordData rd_new[rd_count_new]; | ||
841 | |||
842 | unsigned int c2 = 0; | ||
843 | for (c = 0; c < rd_count; c++) | ||
844 | { | ||
845 | if (c != found) | ||
846 | { | ||
847 | GNUNET_assert (c2 < rd_count_new); | ||
848 | rd_new[c2] = rd[c]; | ||
849 | c2++; | ||
850 | } | ||
851 | } | ||
852 | |||
844 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name `%s' now has %u records\n", name, rd_count_new); | 853 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name `%s' now has %u records\n", name, rd_count_new); |
845 | 854 | ||
846 | /* Create new signature */ | 855 | /* Create new signature */ |