Mercurial > pidgin
comparison src/stringref.c @ 7767:1f4005fcd872
[gaim-migrate @ 8412]
As Nathan pointed out, a printf'd stringref is probably desirable
committer: Tailor Script <tailor@pidgin.im>
| author | Ethan Blanton <elb@pidgin.im> |
|---|---|
| date | Fri, 05 Dec 2003 17:28:22 +0000 |
| parents | dc79649b829d |
| children | 4e5c48ea9478 |
comparison
equal
deleted
inserted
replaced
| 7766:9d6ba1c44cb7 | 7767:1f4005fcd872 |
|---|---|
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "internal.h" | 25 #include "internal.h" |
| 26 | 26 |
| 27 #include <string.h> | 27 #include <string.h> |
| 28 #include <stdarg.h> | |
| 28 | 29 |
| 29 #include "stringref.h" | 30 #include "stringref.h" |
| 30 | 31 |
| 31 GaimStringref *gaim_stringref_new(const char *value) | 32 GaimStringref *gaim_stringref_new(const char *value) |
| 32 { | 33 { |
| 33 GaimStringref *newref; | 34 GaimStringref *newref; |
| 34 | 35 |
| 35 newref = g_malloc(sizeof(GaimStringref) + strlen(value) + 1); | 36 newref = g_malloc(sizeof(GaimStringref) + strlen(value) + 1); |
| 36 strcpy(newref->value, value); | 37 strcpy(newref->value, value); |
| 37 newref->ref = 1; | 38 newref->ref = 1; |
| 39 | |
| 40 return newref; | |
| 41 } | |
| 42 | |
| 43 GaimStringref *gaim_stringref_printf(const char *format, ...) | |
| 44 { | |
| 45 GaimStringref *newref; | |
| 46 va_list ap; | |
| 47 | |
| 48 if (format == NULL) | |
| 49 return NULL; | |
| 50 | |
| 51 va_start(ap, format); | |
| 52 newref = g_malloc(sizeof(GaimStringref) + g_printf_string_upper_bound(format, ap)); | |
| 53 vsprintf(newref->value, format, ap); | |
| 54 va_end(ap); | |
| 38 | 55 |
| 39 return newref; | 56 return newref; |
| 40 } | 57 } |
| 41 | 58 |
| 42 GaimStringref *gaim_stringref_ref(GaimStringref *stringref) | 59 GaimStringref *gaim_stringref_ref(GaimStringref *stringref) |
