diff options
Diffstat (limited to 'dlib/dlib.c')
-rw-r--r-- | dlib/dlib.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/dlib/dlib.c b/dlib/dlib.c index b8786c15..78fa951d 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -210,7 +210,7 @@ Dstr *dStr_sized_new (int sz) Dstr *ds = dNew(Dstr, 1); ds->str = NULL; - dStr_resize(ds, sz, 0); + dStr_resize(ds, sz + 1, 0); /* (sz + 1) for the extra '\0' */ return ds; } @@ -403,6 +403,18 @@ void dStr_sprintfa (Dstr *ds, const char *format, ...) } /* + * Compare two dStrs. + */ +int dStr_cmp(Dstr *ds1, Dstr *ds2) +{ + int ret = 0; + + if (ds1 && ds2) + ret = memcmp(ds1->str, ds2->str, MIN(ds1->len+1, ds2->len+1)); + return ret; +} + +/* *- dList --------------------------------------------------------------------- */ |