1
/* Copyright (C) 2007 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18
#include <drizzled/internal/my_sys.h>
19
#include <drizzled/internal/m_string.h>
27
Append str to array, or move to the end if it already exists
29
@param str String to be appended
30
@param array The array, terminated by a NULL element, all unused elements
31
pre-initialized to NULL
32
@param size Size of the array; array must be terminated by a NULL
33
pointer, so can hold size - 1 elements
36
@retval true Failure, array is full
39
bool array_append_string_unique(const char *str,
40
const char **array, size_t size)
43
/* end points at the terminating NULL element */
44
const char **end= array + size - 1;
47
for (p= array; *p; ++p)
49
if (strcmp(*p, str) == 0)
53
return true; /* Array is full */
55
assert(*p == NULL || strcmp(*p, str) == 0);
66
return false; /* Success */
69
} /* namespace internal */
70
} /* namespace drizzled */