1
by brian
clean slate |
1 |
/* Copyright (C) 2007 MySQL AB
|
2 |
||
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.
|
|
6 |
||
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.
|
|
11 |
||
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
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
15 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
16 |
#include <config.h> |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
17 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
18 |
#include <drizzled/internal/my_sys.h> |
19 |
#include <drizzled/internal/m_string.h> |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
20 |
|
21 |
namespace drizzled |
|
22 |
{
|
|
23 |
namespace internal |
|
24 |
{
|
|
1
by brian
clean slate |
25 |
|
26 |
/**
|
|
27 |
Append str to array, or move to the end if it already exists
|
|
28 |
||
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
|
|
34 |
||
163
by Brian Aker
Merge Monty's code. |
35 |
@retval false Success
|
36 |
@retval true Failure, array is full
|
|
1
by brian
clean slate |
37 |
*/
|
38 |
||
146
by Brian Aker
my_bool cleanup. |
39 |
bool array_append_string_unique(const char *str, |
1
by brian
clean slate |
40 |
const char **array, size_t size) |
41 |
{
|
|
42 |
const char **p; |
|
43 |
/* end points at the terminating NULL element */
|
|
44 |
const char **end= array + size - 1; |
|
51.3.22
by Jay Pipes
Final round of removal of DBUG in mysys/, including Makefile |
45 |
assert(*end == NULL); |
1
by brian
clean slate |
46 |
|
47 |
for (p= array; *p; ++p) |
|
48 |
{
|
|
49 |
if (strcmp(*p, str) == 0) |
|
50 |
break; |
|
51 |
}
|
|
52 |
if (p >= end) |
|
163
by Brian Aker
Merge Monty's code. |
53 |
return true; /* Array is full */ |
1
by brian
clean slate |
54 |
|
51.3.22
by Jay Pipes
Final round of removal of DBUG in mysys/, including Makefile |
55 |
assert(*p == NULL || strcmp(*p, str) == 0); |
1
by brian
clean slate |
56 |
|
57 |
while (*(p + 1)) |
|
58 |
{
|
|
59 |
*p= *(p + 1); |
|
60 |
++p; |
|
61 |
}
|
|
62 |
||
51.3.22
by Jay Pipes
Final round of removal of DBUG in mysys/, including Makefile |
63 |
assert(p < end); |
1
by brian
clean slate |
64 |
*p= str; |
65 |
||
163
by Brian Aker
Merge Monty's code. |
66 |
return false; /* Success */ |
1
by brian
clean slate |
67 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
68 |
|
69 |
} /* namespace internal */ |
|
70 |
} /* namespace drizzled */ |