]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/schema.c
We'll need queue macros in -llber...
[openldap] / libraries / libldap / schema.c
index 6f7020846923a8ca676eca4f4daa811911f7b24e..e77f063328b2661e66d06457c143c1d2988c4772 100644 (file)
@@ -798,7 +798,7 @@ parse_whsp(const char **sp)
 
 /* Parse a sequence of dot-separated decimal strings */
 char *
-parse_numericoid(const char **sp, int *code, const int flags)
+ldap_int_parse_numericoid(const char **sp, int *code, const int flags)
 {
        char * res = NULL;
        const char * start = *sp;
@@ -840,7 +840,7 @@ parse_numericoid(const char **sp, int *code, const int flags)
                }
        }
        if (flags & LDAP_SCHEMA_SKIP) {
-               res = start;
+               res = (char *)start;
        } else {
                res = LDAP_MALLOC(len+1);
                if (!res) {
@@ -953,7 +953,7 @@ parse_noidlen(const char **sp, int *code, int *len, int allow_quoted)
                quoted = 1;
                (*sp)++;
        }
-       sval = parse_numericoid(sp, code, 0);
+       sval = ldap_int_parse_numericoid(sp, code, 0);
        if ( !sval ) {
                return NULL;
        }
@@ -1140,8 +1140,8 @@ void
 ldap_syntax_free( LDAPSyntax * syn )
 {
        LDAP_FREE(syn->syn_oid);
-       LDAP_VFREE(syn->syn_names);
-       LDAP_FREE(syn->syn_desc);
+       if (syn->syn_names) LDAP_VFREE(syn->syn_names);
+       if (syn->syn_desc) LDAP_FREE(syn->syn_desc);
        free_extensions(syn->syn_extensions);
        LDAP_FREE(syn);
 }
@@ -1183,7 +1183,7 @@ ldap_str2syntax( LDAP_CONST char * s,
        }
 
        parse_whsp(&ss);
-       syn->syn_oid = parse_numericoid(&ss,code,0);
+       syn->syn_oid = ldap_int_parse_numericoid(&ss,code,0);
        if ( !syn->syn_oid ) {
                *errp = ss;
                ldap_syntax_free(syn);
@@ -1281,9 +1281,9 @@ void
 ldap_matchingrule_free( LDAPMatchingRule * mr )
 {
        LDAP_FREE(mr->mr_oid);
-       LDAP_VFREE(mr->mr_names);
-       LDAP_FREE(mr->mr_desc);
-       LDAP_FREE(mr->mr_syntax_oid);
+       if (mr->mr_names) LDAP_VFREE(mr->mr_names);
+       if (mr->mr_desc) LDAP_FREE(mr->mr_desc);
+       if (mr->mr_syntax_oid) LDAP_FREE(mr->mr_syntax_oid);
        free_extensions(mr->mr_extensions);
        LDAP_FREE(mr);
 }
@@ -1329,7 +1329,7 @@ ldap_str2matchingrule( LDAP_CONST char * s,
 
        parse_whsp(&ss);
        savepos = ss;
-       mr->mr_oid = parse_numericoid(&ss,code,flags);
+       mr->mr_oid = ldap_int_parse_numericoid(&ss,code,flags);
        if ( !mr->mr_oid ) {
                if ( flags & LDAP_SCHEMA_ALLOW_NO_OID ) {
                        /* Backtracking */
@@ -1430,7 +1430,7 @@ ldap_str2matchingrule( LDAP_CONST char * s,
                                seen_syntax = 1;
                                parse_whsp(&ss);
                                mr->mr_syntax_oid =
-                                       parse_numericoid(&ss,code,flags);
+                                       ldap_int_parse_numericoid(&ss,code,flags);
                                if ( !mr->mr_syntax_oid ) {
                                        *errp = ss;
                                        ldap_matchingrule_free(mr);
@@ -1475,9 +1475,9 @@ void
 ldap_matchingruleuse_free( LDAPMatchingRuleUse * mru )
 {
        LDAP_FREE(mru->mru_oid);
-       LDAP_VFREE(mru->mru_names);
-       LDAP_FREE(mru->mru_desc);
-       LDAP_VFREE(mru->mru_applies_oids);
+       if (mru->mru_names) LDAP_VFREE(mru->mru_names);
+       if (mru->mru_desc) LDAP_FREE(mru->mru_desc);
+       if (mru->mru_applies_oids) LDAP_VFREE(mru->mru_applies_oids);
        free_extensions(mru->mru_extensions);
        LDAP_FREE(mru);
 }
@@ -1523,7 +1523,7 @@ ldap_str2matchingruleuse( LDAP_CONST char * s,
 
        parse_whsp(&ss);
        savepos = ss;
-       mru->mru_oid = parse_numericoid(&ss,code,flags);
+       mru->mru_oid = ldap_int_parse_numericoid(&ss,code,flags);
        if ( !mru->mru_oid ) {
                if ( flags & LDAP_SCHEMA_ALLOW_NO_OID ) {
                        /* Backtracking */
@@ -1668,13 +1668,13 @@ void
 ldap_attributetype_free(LDAPAttributeType * at)
 {
        LDAP_FREE(at->at_oid);
-       LDAP_VFREE(at->at_names);
-       LDAP_FREE(at->at_desc);
-       LDAP_FREE(at->at_sup_oid);
-       LDAP_FREE(at->at_equality_oid);
-       LDAP_FREE(at->at_ordering_oid);
-       LDAP_FREE(at->at_substr_oid);
-       LDAP_FREE(at->at_syntax_oid);
+       if (at->at_names) LDAP_VFREE(at->at_names);
+       if (at->at_desc) LDAP_FREE(at->at_desc);
+       if (at->at_sup_oid) LDAP_FREE(at->at_sup_oid);
+       if (at->at_equality_oid) LDAP_FREE(at->at_equality_oid);
+       if (at->at_ordering_oid) LDAP_FREE(at->at_ordering_oid);
+       if (at->at_substr_oid) LDAP_FREE(at->at_substr_oid);
+       if (at->at_syntax_oid) LDAP_FREE(at->at_syntax_oid);
        free_extensions(at->at_extensions);
        LDAP_FREE(at);
 }
@@ -1732,7 +1732,7 @@ ldap_str2attributetype( LDAP_CONST char * s,
         */
        parse_whsp(&ss);
        savepos = ss;
-       at->at_oid = parse_numericoid(&ss,code,0);
+       at->at_oid = ldap_int_parse_numericoid(&ss,code,0);
        if ( !at->at_oid ) {
                if ( ( flags & ( LDAP_SCHEMA_ALLOW_NO_OID
                                | LDAP_SCHEMA_ALLOW_OID_MACRO ) )
@@ -2048,11 +2048,11 @@ void
 ldap_objectclass_free(LDAPObjectClass * oc)
 {
        LDAP_FREE(oc->oc_oid);
-       LDAP_VFREE(oc->oc_names);
-       LDAP_FREE(oc->oc_desc);
-       LDAP_VFREE(oc->oc_sup_oids);
-       LDAP_VFREE(oc->oc_at_oids_must);
-       LDAP_VFREE(oc->oc_at_oids_may);
+       if (oc->oc_names) LDAP_VFREE(oc->oc_names);
+       if (oc->oc_desc) LDAP_FREE(oc->oc_desc);
+       if (oc->oc_sup_oids) LDAP_VFREE(oc->oc_sup_oids);
+       if (oc->oc_at_oids_must) LDAP_VFREE(oc->oc_at_oids_must);
+       if (oc->oc_at_oids_may) LDAP_VFREE(oc->oc_at_oids_may);
        free_extensions(oc->oc_extensions);
        LDAP_FREE(oc);
 }
@@ -2109,7 +2109,7 @@ ldap_str2objectclass( LDAP_CONST char * s,
         */
        parse_whsp(&ss);
        savepos = ss;
-       oc->oc_oid = parse_numericoid(&ss,code,0);
+       oc->oc_oid = ldap_int_parse_numericoid(&ss,code,0);
        if ( !oc->oc_oid ) {
                if ( (flags & LDAP_SCHEMA_ALLOW_ALL) && (ss == savepos) ) {
                        /* Backtracking */