First fromstr function implemented.

FossilOrigin-Name: b22bdf8b910513722aa8a699f22438d9ecf1567fd894876a412f759c160e2f07
This commit is contained in:
7u83@mail.ru 2015-05-01 10:49:39 +00:00
parent 10b31c61d6
commit 798c1996b7
1 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,17 @@ static int mbag_strstr(void *item,char *dst)
return sprintf(dst, "%s", (char*)i->data);
}
static struct mbag_item * mbag_fromstr(const char *src)
{
struct mbag_item *i= malloc(sizeof(mbag_item_t));
if (!i)
return NULL;
i->type = MBAG_STR;
i->data = strdup(src);
return i;
}
const struct mbag_typedef mbag_type_byte = {
@ -57,7 +68,7 @@ const struct mbag_typedef mbag_type_bstr16 = {
};
const struct mbag_typedef mbag_type_str = {
"str",free,mbag_strstr
"str",free,mbag_strstr,mbag_fromstr
};
const struct mbag_typedef mbag_type_vendorstr = {