strbuffer_value: Return a read-only pointer rather than duplicating the value

This commit is contained in:
Petri Lehtinen 2009-06-13 22:26:45 +03:00
parent 3e0134782b
commit 8c697312e4
3 changed files with 4 additions and 4 deletions

View file

@ -222,7 +222,7 @@ char *json_dumps(const json_t *json, uint32_t flags)
if(dump_to_strbuffer("\n", 1, (void *)&strbuff))
return NULL;
result = strbuffer_value(&strbuff);
result = strdup(strbuffer_value(&strbuff));
strbuffer_close(&strbuff);
return result;

View file

@ -20,9 +20,9 @@ void strbuffer_close(strbuffer_t *strbuff)
strbuffer_init(strbuff);
}
char *strbuffer_value(strbuffer_t *strbuff)
const char *strbuffer_value(strbuffer_t *strbuff)
{
return strdup(strbuff->value);
return strbuff->value;
}
char *strbuffer_steal_value(strbuffer_t *strbuff)

View file

@ -10,7 +10,7 @@ typedef struct {
void strbuffer_init(strbuffer_t *strbuff);
void strbuffer_close(strbuffer_t *strbuff);
char *strbuffer_value(strbuffer_t *strbuff);
const char *strbuffer_value(strbuffer_t *strbuff);
char *strbuffer_steal_value(strbuffer_t *strbuff);
int strbuffer_append(strbuffer_t *strbuff, const char *string);