! * \brief sarrayGetString() * * \param[in] sa string array * \param[in] index to the index-th string * \param[in] copyflag L_NOCOPY or L_COPY * \return string, or NULL on error * * * Notes: * (1) See usage comments at the top of this file. * (2) To get a pointer to the string itself, use L_NOCOPY. * To get a copy of the string, use L_COPY. * </
| 679 | * </pre> |
| 680 | */ |
| 681 | char * |
| 682 | sarrayGetString(SARRAY *sa, |
| 683 | l_int32 index, |
| 684 | l_int32 copyflag) |
| 685 | { |
| 686 | PROCNAME("sarrayGetString"); |
| 687 | |
| 688 | if (!sa) |
| 689 | return (char *)ERROR_PTR("sa not defined", procName, NULL); |
| 690 | if (index < 0 || index >= sa->n) |
| 691 | return (char *)ERROR_PTR("index not valid", procName, NULL); |
| 692 | if (copyflag != L_NOCOPY && copyflag != L_COPY) |
| 693 | return (char *)ERROR_PTR("invalid copyflag", procName, NULL); |
| 694 | |
| 695 | if (copyflag == L_NOCOPY) |
| 696 | return sa->array[index]; |
| 697 | else /* L_COPY */ |
| 698 | return stringNew(sa->array[index]); |
| 699 | } |
| 700 | |
| 701 | |
| 702 | /*! |
no test coverage detected