~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/egl/main/eglarray.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *
26
26
 **************************************************************************/
27
27
 
28
 
 
29
28
#include <assert.h>
30
29
#include <stdlib.h>
31
30
#include <string.h>
32
31
 
 
32
#include "eglarray.h"
33
33
#include "egllog.h"
34
 
#include "eglarray.h"
35
 
 
36
34
 
37
35
/**
38
36
 * Grow the size of the array.
49
47
 
50
48
   elems = realloc(array->Elements, new_size * sizeof(array->Elements[0]));
51
49
   if (!elems) {
52
 
      _eglLog(_EGL_DEBUG, "failed to grow %s array to %d",
53
 
            array->Name, new_size);
 
50
      _eglLog(_EGL_DEBUG, "failed to grow %s array to %d", array->Name,
 
51
              new_size);
54
52
      return EGL_FALSE;
55
53
   }
56
54
 
60
58
   return EGL_TRUE;
61
59
}
62
60
 
63
 
 
64
61
/**
65
62
 * Create an array.
66
63
 */
82
79
   return array;
83
80
}
84
81
 
85
 
 
86
82
/**
87
83
 * Destroy an array, optionally free the data.
88
84
 */
98
94
   free(array);
99
95
}
100
96
 
101
 
 
102
97
/**
103
98
 * Append a element to an array.
104
99
 */
111
106
   array->Elements[array->Size++] = elem;
112
107
}
113
108
 
114
 
 
115
109
/**
116
110
 * Erase an element from an array.
117
111
 */
122
116
      free_cb(array->Elements[i]);
123
117
   if (i < array->Size - 1) {
124
118
      memmove(&array->Elements[i], &array->Elements[i + 1],
125
 
            (array->Size - i - 1) * sizeof(array->Elements[0]));
 
119
              (array->Size - i - 1) * sizeof(array->Elements[0]));
126
120
   }
127
121
   array->Size--;
128
122
}
129
123
 
130
 
 
131
124
/**
132
125
 * Find in an array for the given element.
133
126
 */
145
138
   return NULL;
146
139
}
147
140
 
148
 
 
149
141
/**
150
142
 * Filter an array and return the number of filtered elements.
151
143
 */
172
164
   return count;
173
165
}
174
166
 
175
 
 
176
167
/**
177
168
 * Flatten an array by converting array elements into another form and store
178
169
 * them in a buffer.
195
186
      if (count > size)
196
187
         count = size;
197
188
      for (i = 0; i < count; i++)
198
 
         flatten(array->Elements[i],
199
 
               (void *) ((char *) buffer + elem_size * i));
 
189
         flatten(array->Elements[i], (void *)((char *)buffer + elem_size * i));
200
190
   }
201
191
 
202
192
   return count;