[fix] update feature arrays to use the new APIs

This commit is contained in:
Al
2015-03-27 20:57:42 -04:00
parent 6768936953
commit 4ccd1b1fe2
2 changed files with 12 additions and 9 deletions

View File

@@ -1,22 +1,25 @@
#include "features.h" #include "features.h"
void feature_array_add(char_array *features, int num_args, ...) {
if (num_args <= 0) { void feature_array_add(cstring_array_t *features, size_t count, ...) {
if (count <= 0) {
return; return;
} }
va_list args; va_list args;
va_start(args, num_args); va_start(args, count);
for (int i = 0; i < num_args - 1; i++) { cstring_array_start_token(features);
for (size_t i = 0; i < count - 1; i++) {
char *arg = va_arg(args, char *); char *arg = va_arg(args, char *);
contiguous_string_array_add_string_unterminated(features, arg); char_array_append(features->str, arg);
contiguous_string_array_add_string_unterminated(features, FEATURE_SEPARATOR_CHAR); char_array_append(features->str, FEATURE_SEPARATOR_CHAR);
} }
char *arg = va_arg(args, char *); char *arg = va_arg(args, char *);
contiguous_string_array_add_string(features, arg); char_array_append(features->str, arg);
char_array_terminate(features->str);
va_end(args); va_end(args);
} }

View File

@@ -12,7 +12,7 @@ extern "C" {
#define FEATURE_SEPARATOR_CHAR "|" #define FEATURE_SEPARATOR_CHAR "|"
void feature_array_add(char_array *features, int num_args, ...); void feature_array_add(contiguous_string_array_t *features, size_t count, ...);
#ifdef __cplusplus #ifdef __cplusplus