1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
|
25 mike 1.2 #include <stdlib.h>
26 #include <assert.h>
27 #include <string.h>
28 #include "ptrarray.h"
29 #include "types.h"
30 #include "state.h"
31
32 int PtrArray_Append(PtrArray* self, void* ptr)
33 {
34 MOF_ASSERT(self != NULL);
35 MOF_ASSERT(ptr != NULL);
36
37 if (!self || !ptr)
38 return -1;
39
40 self->data = (void**)MOF_Realloc(&state.heap,
41 self->data, sizeof(void*) * (self->size + 1));
42
43 if (!self->data)
44 {
45 yyerrorf(ID_OUT_OF_MEMORY, "out of memory");
46 mike 1.2 return -1;
47 }
48
49 self->data[self->size++] = ptr;
50
51 return 0;
52 }
53
|