summaryrefslogtreecommitdiffhomepage
path: root/common-algo.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2005-09-02 15:35:18 +0000
committerMatt Johnston <matt@ucc.asn.au>2005-09-02 15:35:18 +0000
commit5a6404712c54bb3b5746467e6b84baf9d42864b0 (patch)
tree8a679f9a1ea9325647bde9dcff2ddc4f66498e70 /common-algo.c
parentb332e4aaf9c1a6c883e9eda83ee53a8b963aff47 (diff)
use a buffer rather than raw char array for creating
the comma-seperated algorithm lists --HG-- extra : convert_revision : bd00bc1e914dc1a816e9a2cca38c7bd3b6865dd0
Diffstat (limited to 'common-algo.c')
-rw-r--r--common-algo.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/common-algo.c b/common-algo.c
index 21e39a2..6ce1a37 100644
--- a/common-algo.c
+++ b/common-algo.c
@@ -209,21 +209,20 @@ int have_algo(char* algo, size_t algolen, algo_type algos[]) {
/* Output a comma separated list of algorithms to a buffer */
void buf_put_algolist(buffer * buf, algo_type localalgos[]) {
- unsigned int pos = 0, i, len;
- char str[50]; /* enough for local algo storage */
+ unsigned int i, len;
+ unsigned int donefirst = 0;
+ buffer *algolist = NULL;
+ algolist = buf_new(100);
for (i = 0; localalgos[i].name != NULL; i++) {
if (localalgos[i].usable) {
- /* Avoid generating a trailing comma */
- if (pos)
- str[pos++] = ',';
+ if (donefirst)
+ buf_putbyte(algolist, ',');
+ donefirst = 1;
len = strlen(localalgos[i].name);
- memcpy(&str[pos], localalgos[i].name, len);
- pos += len;
+ buf_putbytes(algolist, localalgos[i].name, len);
}
}
- str[pos]=0;
- /* Debug this */
- TRACE(("buf_put_algolist: %s", str))
- buf_putstring(buf, str, pos);
+ buf_putstring(buf, algolist->data, algolist->len);
+ buf_free(algolist);
}