def_glist = (avp_list_t*)shm_malloc(sizeof(avp_list_t));
crt_glist = (avp_list_t**)shm_malloc(sizeof(avp_list_t*));
if (!def_glist || !crt_glist) {
- LM_ERR("No memory to allocate default global AVP list\n");
+ SHM_MEM_ERROR;
return -1;
}
*def_glist = 0;
struct str_str_data *ssd;
int len;
- if (name.s.s == 0 && name.s.len == 0) {
+ if (name.s.s == NULL || name.s.len == 0) {
LM_ERR("0 ID or NULL NAME AVP!");
goto error;
}
avp = (struct usr_avp*)shm_malloc( len );
if (avp==0) {
- LM_ERR("no more shm mem\n");
+ SHM_MEM_ERROR;
return 0;
}
break;
}
- if (!state) state = &st;
+ if (!state) {
+ memset(&st, 0, sizeof(struct search_state));
+ state = &st;
+ }
if ((ident.flags & AVP_CLASS_ALL) == 0) {
/* The caller did not specify any class to search in, so enable
state->avp = *list;
state->name = ident.name;
- if (ident.flags & AVP_NAME_STR) {
+ if(ident.flags & AVP_NAME_STR) {
state->id = compute_ID(&ident.name.s);
}
- ret = search_next_avp(state, val);
+ ret = search_next_avp(state, val);
- /* Make sure that search next avp stays in the same class as the first
- * avp found
- */
- if (state && ret) state->flags = (ident.flags & ~AVP_CLASS_ALL) | (ret->flags & AVP_CLASS_ALL);
+ /* Make sure that search next avp stays in the same class as the first
+ * avp found */
+ if(ret) {
+ state->flags =
+ (ident.flags & ~AVP_CLASS_ALL) | (ret->flags & AVP_CLASS_ALL);
+ }
return ret;
}
ga = (struct avp_galias*)pkg_malloc( sizeof(struct avp_galias) );
if (ga==0) {
- LM_ERR("no more pkg memory\n");
+ PKG_MEM_ERROR;
goto error;
}
ga->alias.s = (char*)pkg_malloc( alias->len+1 );
if (ga->alias.s==0) {
- LM_ERR("no more pkg memory\n");
+ PKG_MEM_ERROR;
goto error1;
}
memcpy( ga->alias.s, alias->s, alias->len);
if (type&AVP_NAME_STR) {
ga->avp.name.s.s = (char*)pkg_malloc( avp_name.s.len+1 );
if (ga->avp.name.s.s==0) {
- LM_ERR("no more pkg memory\n");
+ PKG_MEM_ERROR;
goto error2;
}
ga->avp.name.s.len = avp_name.s.len;
if ((name->len > 2) && (name->s[0]=='/') && (name->s[name->len-1]=='/')) {
attr->name.re=pkg_malloc(sizeof(regex_t));
if (!attr->name.re) {
- BUG("No free memory to allocate AVP_NAME_RE regex\n");
+ PKG_MEM_ERROR;
goto error;
}
name->s[name->len-1]=0;