mutt stable branch with some hacks
0
fork

Configure Feed

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

Convert hcache delete and open calls to use buffer pool.

+72 -42
+72 -42
hcache.c
··· 1030 1030 mutt_hcache_delete(header_cache_t *h, const char *filename, 1031 1031 size_t(*keylen) (const char *fn)) 1032 1032 { 1033 - char path[_POSIX_PATH_MAX]; 1034 - int ksize; 1033 + BUFFER *path = NULL; 1034 + int ksize, rc; 1035 1035 1036 1036 if (!h) 1037 1037 return -1; 1038 1038 1039 - strncpy(path, h->folder, sizeof (path)); 1040 - safe_strcat(path, sizeof (path), filename); 1039 + path = mutt_buffer_pool_get (); 1040 + mutt_buffer_strcpy (path, h->folder); 1041 + mutt_buffer_addstr (path, filename); 1041 1042 1042 - ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); 1043 + ksize = strlen(h->folder) + keylen(filename); 1043 1044 1044 - return vlout(h->db, path, ksize); 1045 + rc = vlout(h->db, mutt_b2s (path), ksize); 1046 + 1047 + mutt_buffer_pool_release (&path); 1048 + return rc; 1045 1049 } 1046 1050 1047 1051 #elif HAVE_TC ··· 1088 1092 mutt_hcache_delete(header_cache_t *h, const char *filename, 1089 1093 size_t(*keylen) (const char *fn)) 1090 1094 { 1091 - char path[_POSIX_PATH_MAX]; 1092 - int ksize; 1095 + BUFFER *path = NULL; 1096 + int ksize, rc; 1093 1097 1094 1098 if (!h) 1095 1099 return -1; 1096 1100 1097 - strncpy(path, h->folder, sizeof (path)); 1098 - safe_strcat(path, sizeof (path), filename); 1101 + path = mutt_buffer_pool_get (); 1102 + mutt_buffer_strcpy (path, h->folder); 1103 + mutt_buffer_addstr (path, filename); 1099 1104 1100 - ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); 1105 + ksize = strlen(h->folder) + keylen(filename); 1106 + 1107 + rc = tcbdbout(h->db, mutt_b2s (path), ksize); 1101 1108 1102 - return tcbdbout(h->db, path, ksize); 1109 + mutt_buffer_pool_release (&path); 1110 + return rc; 1103 1111 } 1104 1112 1105 1113 #elif HAVE_KC 1106 1114 static int 1107 1115 hcache_open_kc (struct header_cache* h, const char* path) 1108 1116 { 1109 - char fullpath[_POSIX_PATH_MAX]; 1117 + BUFFER *fullpath = NULL; 1118 + int rc = -1; 1119 + 1120 + fullpath = mutt_buffer_pool_get (); 1110 1121 1111 1122 /* Kyoto cabinet options are discussed at 1112 1123 * http://fallabs.com/kyotocabinet/spex.html ··· 1115 1126 * this isn't suggested unless you are tuning the number of buckets. 1116 1127 * - opts=c enables compression 1117 1128 */ 1118 - snprintf (fullpath, sizeof(fullpath), "%s#type=kct%s", path, 1119 - option(OPTHCACHECOMPRESS) ? "#opts=c" : ""); 1129 + mutt_buffer_printf (fullpath, "%s#type=kct%s", path, 1130 + option(OPTHCACHECOMPRESS) ? "#opts=c" : ""); 1120 1131 h->db = kcdbnew(); 1121 1132 if (!h->db) 1122 - return -1; 1123 - if (kcdbopen(h->db, fullpath, KCOWRITER | KCOCREATE)) 1124 - return 0; 1125 - else 1133 + goto cleanup; 1134 + if (!kcdbopen(h->db, mutt_b2s (fullpath), KCOWRITER | KCOCREATE)) 1126 1135 { 1127 - dprint (2, (debugfile, "kcdbopen failed for %s: %s (ecode %d)\n", fullpath, 1136 + dprint (2, (debugfile, "kcdbopen failed for %s: %s (ecode %d)\n", 1137 + mutt_b2s (fullpath), 1128 1138 kcdbemsg (h->db), kcdbecode (h->db))); 1129 1139 kcdbdel(h->db); 1130 - return -1; 1140 + goto cleanup; 1131 1141 } 1142 + 1143 + rc = 0; 1144 + 1145 + cleanup: 1146 + mutt_buffer_pool_release (&fullpath); 1147 + return rc; 1132 1148 } 1133 1149 1134 1150 void ··· 1149 1165 mutt_hcache_delete(header_cache_t *h, const char *filename, 1150 1166 size_t(*keylen) (const char *fn)) 1151 1167 { 1152 - char path[_POSIX_PATH_MAX]; 1153 - int ksize; 1168 + BUFFER *path = NULL; 1169 + int ksize, rc; 1154 1170 1155 1171 if (!h) 1156 1172 return -1; 1157 1173 1158 - strncpy(path, h->folder, sizeof (path)); 1159 - safe_strcat(path, sizeof (path), filename); 1174 + path = mutt_buffer_pool_get (); 1175 + mutt_buffer_strcpy (path, h->folder); 1176 + mutt_buffer_addstr (path, filename); 1160 1177 1161 - ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); 1178 + ksize = strlen(h->folder) + keylen(filename); 1162 1179 1163 - return kcdbremove(h->db, path, ksize); 1180 + rc = kcdbremove(h->db, mutt_b2s (path), ksize); 1181 + 1182 + mutt_buffer_pool_release (&path); 1183 + return rc; 1164 1184 } 1165 1185 1166 1186 #elif HAVE_GDBM ··· 1201 1221 size_t(*keylen) (const char *fn)) 1202 1222 { 1203 1223 datum key; 1204 - char path[_POSIX_PATH_MAX]; 1224 + BUFFER *path = NULL; 1225 + int rc; 1205 1226 1206 1227 if (!h) 1207 1228 return -1; 1208 1229 1209 - strncpy(path, h->folder, sizeof (path)); 1210 - safe_strcat(path, sizeof (path), filename); 1230 + path = mutt_buffer_pool_get (); 1231 + mutt_buffer_strcpy (path, h->folder); 1232 + mutt_buffer_addstr (path, filename); 1233 + 1234 + key.dptr = path->data; 1235 + key.dsize = strlen(h->folder) + keylen(filename); 1211 1236 1212 - key.dptr = path; 1213 - key.dsize = strlen(h->folder) + keylen(path + strlen(h->folder)); 1237 + rc = gdbm_delete(h->db, key); 1214 1238 1215 - return gdbm_delete(h->db, key); 1239 + mutt_buffer_pool_release (&path); 1240 + return rc; 1216 1241 } 1217 1242 #elif HAVE_DB4 1218 1243 ··· 1408 1433 mutt_hcache_delete(header_cache_t *h, const char *filename, 1409 1434 size_t(*keylen) (const char *fn)) 1410 1435 { 1411 - char path[_POSIX_PATH_MAX]; 1436 + BUFFER *path = NULL; 1412 1437 int ksize; 1413 1438 MDB_val key; 1414 - int rc; 1439 + int rc = -1; 1415 1440 1416 1441 if (!h) 1417 1442 return -1; 1418 1443 1419 - strncpy(path, h->folder, sizeof (path)); 1420 - safe_strcat(path, sizeof (path), filename); 1421 - ksize = strlen (h->folder) + keylen (path + strlen (h->folder)); 1444 + path = mutt_buffer_pool_get (); 1445 + mutt_buffer_strcpy (path, h->folder); 1446 + mutt_buffer_addstr (path, filename); 1447 + ksize = strlen (h->folder) + keylen (filename); 1422 1448 1423 - key.mv_data = path; 1449 + key.mv_data = path->data; 1424 1450 key.mv_size = ksize; 1425 1451 if (mdb_get_w_txn(h) != MDB_SUCCESS) 1426 - return -1; 1452 + goto cleanup; 1427 1453 rc = mdb_del(h->txn, h->db, &key, NULL); 1428 1454 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) 1429 1455 { ··· 1432 1458 mdb_txn_abort(h->txn); 1433 1459 h->txn_mode = txn_uninitialized; 1434 1460 h->txn = NULL; 1435 - return -1; 1461 + goto cleanup; 1436 1462 } 1437 1463 1438 - return 0; 1464 + rc = 0; 1465 + 1466 + cleanup: 1467 + mutt_buffer_pool_release (&path); 1468 + return rc; 1439 1469 } 1440 1470 #endif 1441 1471