mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert hcache fetch and store raw to use buffer pool.

+47 -49
+47 -49
hcache.c
··· 798 798 size_t(*keylen) (const char *fn)) 799 799 { 800 800 #ifndef HAVE_DB4 801 - char path[_POSIX_PATH_MAX]; 801 + BUFFER *path = NULL; 802 802 int ksize; 803 + void *rv = NULL; 803 804 #endif 804 - #ifdef HAVE_QDBM 805 - char *data = NULL; 806 - #elif HAVE_TC 807 - void *data; 805 + #if HAVE_TC 808 806 int sp; 809 807 #elif HAVE_KC 810 - void *data; 811 808 size_t sp; 812 809 #elif HAVE_GDBM 813 810 datum key; ··· 834 831 h->db->get(h->db, NULL, &key, &data, 0); 835 832 836 833 return data.data; 834 + 837 835 #else 838 - strncpy(path, h->folder, sizeof (path)); 839 - safe_strcat(path, sizeof (path), filename); 836 + path = mutt_buffer_pool_get (); 837 + mutt_buffer_strcpy (path, h->folder); 838 + mutt_buffer_addstr (path, filename); 840 839 841 - ksize = strlen (h->folder) + keylen (path + strlen (h->folder)); 842 - #endif 840 + ksize = strlen (h->folder) + keylen (filename); 843 841 844 842 #ifdef HAVE_QDBM 845 - data = vlget(h->db, path, ksize, NULL); 846 - 847 - return data; 843 + rv = vlget(h->db, mutt_b2s (path), ksize, NULL); 848 844 #elif HAVE_TC 849 - data = tcbdbget(h->db, path, ksize, &sp); 850 - 851 - return data; 845 + rv = tcbdbget(h->db, mutt_b2s (path), ksize, &sp); 852 846 #elif HAVE_KC 853 - data = kcdbget(h->db, path, ksize, &sp); 854 - 855 - return data; 847 + rv = kcdbget(h->db, mutt_b2s (path), ksize, &sp); 856 848 #elif HAVE_GDBM 857 - key.dptr = path; 849 + key.dptr = path->data; 858 850 key.dsize = ksize; 859 851 860 852 data = gdbm_fetch(h->db, key); 861 853 862 - return data.dptr; 854 + rv = data.dptr; 863 855 #elif HAVE_LMDB 864 - key.mv_data = path; 856 + key.mv_data = path->data; 865 857 key.mv_size = ksize; 866 - if ((mdb_get_r_txn (h) != MDB_SUCCESS) || 867 - (mdb_get (h->txn, h->db, &key, &data) != MDB_SUCCESS)) 868 - return NULL; 869 - 870 858 /* LMDB claims ownership of the returned data, so this will not be 871 859 * freed in mutt_hcache_free(). */ 872 - return data.mv_data; 860 + if ((mdb_get_r_txn (h) == MDB_SUCCESS) && 861 + (mdb_get (h->txn, h->db, &key, &data) == MDB_SUCCESS)) 862 + rv = data.mv_data; 863 + #endif 864 + 865 + mutt_buffer_pool_release (&path); 866 + return rv; 873 867 #endif 874 868 } 875 869 ··· 905 899 size_t dlen, size_t(*keylen) (const char* fn)) 906 900 { 907 901 #ifndef HAVE_DB4 908 - char path[_POSIX_PATH_MAX]; 902 + BUFFER *path = NULL; 909 903 int ksize; 904 + int rv = 0; 910 905 #endif 911 906 #if HAVE_GDBM 912 907 datum key; ··· 917 912 #elif HAVE_LMDB 918 913 MDB_val key; 919 914 MDB_val databuf; 920 - int rc; 921 915 #endif 922 916 923 917 if (!h) ··· 936 930 databuf.ulen = dlen; 937 931 938 932 return h->db->put(h->db, NULL, &key, &databuf, 0); 933 + 939 934 #else 940 - strncpy(path, h->folder, sizeof (path)); 941 - safe_strcat(path, sizeof (path), filename); 935 + path = mutt_buffer_pool_get (); 936 + mutt_buffer_strcpy (path, h->folder); 937 + mutt_buffer_addstr (path, filename); 942 938 943 - ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); 944 - #endif 939 + ksize = strlen(h->folder) + keylen(filename); 945 940 946 941 #if HAVE_QDBM 947 - return vlput(h->db, path, ksize, data, dlen, VL_DOVER); 942 + rv = vlput(h->db, mutt_b2s (path), ksize, data, dlen, VL_DOVER); 948 943 #elif HAVE_TC 949 - return tcbdbput(h->db, path, ksize, data, dlen); 944 + rv = tcbdbput(h->db, mutt_b2s (path), ksize, data, dlen); 950 945 #elif HAVE_KC 951 - return kcdbset(h->db, path, ksize, data, dlen); 946 + rv = kcdbset(h->db, mutt_b2s (path), ksize, data, dlen); 952 947 #elif HAVE_GDBM 953 - key.dptr = path; 948 + key.dptr = path->data; 954 949 key.dsize = ksize; 955 950 956 951 databuf.dsize = dlen; 957 952 databuf.dptr = data; 958 953 959 - return gdbm_store(h->db, key, databuf, GDBM_REPLACE); 954 + rv = gdbm_store(h->db, key, databuf, GDBM_REPLACE); 960 955 #elif HAVE_LMDB 961 - key.mv_data = path; 956 + key.mv_data = path->data; 962 957 key.mv_size = ksize; 963 958 databuf.mv_data = data; 964 959 databuf.mv_size = dlen; 965 - if ((rc = mdb_get_w_txn (h)) != MDB_SUCCESS) 966 - return rc; 967 - 968 - if ((rc = mdb_put (h->txn, h->db, &key, &databuf, 0)) != MDB_SUCCESS) 960 + if ((rv = mdb_get_w_txn (h)) == MDB_SUCCESS) 969 961 { 970 - dprint (2, (debugfile, "mutt_hcache_store_raw: mdb_put: %s\n", 971 - mdb_strerror(rc))); 972 - mdb_txn_abort (h->txn); 973 - h->txn_mode = txn_uninitialized; 974 - h->txn = NULL; 962 + if ((rv = mdb_put (h->txn, h->db, &key, &databuf, 0)) != MDB_SUCCESS) 963 + { 964 + dprint (2, (debugfile, "mutt_hcache_store_raw: mdb_put: %s\n", 965 + mdb_strerror(rv))); 966 + mdb_txn_abort (h->txn); 967 + h->txn_mode = txn_uninitialized; 968 + h->txn = NULL; 969 + } 975 970 } 976 - return rc; 971 + #endif 972 + 973 + mutt_buffer_pool_release (&path); 974 + return rv; 977 975 #endif 978 976 } 979 977