* xmlRegCopyAtom: * @ctxt: the regexp parser context * @atom: the original atom * * Allocate a new regexp range * * Returns the new atom or NULL in case of error */
| 829 | * Returns the new atom or NULL in case of error |
| 830 | */ |
| 831 | static xmlRegAtomPtr |
| 832 | xmlRegCopyAtom(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom) { |
| 833 | xmlRegAtomPtr ret; |
| 834 | |
| 835 | ret = (xmlRegAtomPtr) xmlMalloc(sizeof(xmlRegAtom)); |
| 836 | if (ret == NULL) { |
| 837 | xmlRegexpErrMemory(ctxt); |
| 838 | return(NULL); |
| 839 | } |
| 840 | memset(ret, 0, sizeof(xmlRegAtom)); |
| 841 | ret->type = atom->type; |
| 842 | ret->quant = atom->quant; |
| 843 | ret->min = atom->min; |
| 844 | ret->max = atom->max; |
| 845 | if (atom->nbRanges > 0) { |
| 846 | int i; |
| 847 | |
| 848 | ret->ranges = (xmlRegRangePtr *) xmlMalloc(sizeof(xmlRegRangePtr) * |
| 849 | atom->nbRanges); |
| 850 | if (ret->ranges == NULL) { |
| 851 | xmlRegexpErrMemory(ctxt); |
| 852 | goto error; |
| 853 | } |
| 854 | for (i = 0;i < atom->nbRanges;i++) { |
| 855 | ret->ranges[i] = xmlRegCopyRange(ctxt, atom->ranges[i]); |
| 856 | if (ret->ranges[i] == NULL) |
| 857 | goto error; |
| 858 | ret->nbRanges = i + 1; |
| 859 | } |
| 860 | } |
| 861 | return(ret); |
| 862 | |
| 863 | error: |
| 864 | xmlRegFreeAtom(ret); |
| 865 | return(NULL); |
| 866 | } |
| 867 | |
| 868 | static xmlRegStatePtr |
| 869 | xmlRegNewState(xmlRegParserCtxtPtr ctxt) { |
no test coverage detected