aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/libbindle/larray.c
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-08-26 01:48:26 -0800
committerDavid M. Syzdek <david@syzdek.net>2022-08-26 01:48:26 -0800
commit18a8f6b5f5550697e0cbd61a5395f71d0c2642bf (patch)
treeff759e0f6025687202b6fb09c5cde823599886cf /lib/libbindle/larray.c
parente6387df7443d6f853a29e3c1ff51ecc6bffa9966 (diff)
downloadbindletools-18a8f6b5f5550697e0cbd61a5395f71d0c2642bf.tar.gz
bindletools-18a8f6b5f5550697e0cbd61a5395f71d0c2642bf.tar.bz2
bindletools-18a8f6b5f5550697e0cbd61a5395f71d0c2642bf.tar.xz
bindletools-18a8f6b5f5550697e0cbd61a5395f71d0c2642bf.zip
libbindle: replacing bindle_array_move() with memcpy()
Diffstat (limited to 'lib/libbindle/larray.c')
-rw-r--r--lib/libbindle/larray.c40
1 files changed, 8 insertions, 32 deletions
diff --git a/lib/libbindle/larray.c b/lib/libbindle/larray.c
index 307e266..839d062 100644
--- a/lib/libbindle/larray.c
+++ b/lib/libbindle/larray.c
@@ -51,12 +51,6 @@
51////////////////// 51//////////////////
52#pragma mark - Prototypes 52#pragma mark - Prototypes
53 53
54static void
55bindle_array_move(
56 void * a,
57 void * b,
58 size_t size );
59
60 54
61///////////////// 55/////////////////
62// // 56// //
@@ -105,7 +99,7 @@ bindle_badd(
105 *basep = ptr; 99 *basep = ptr;
106 }; 100 };
107 (*nelp)++; 101 (*nelp)++;
108 bindle_array_move(obj, *basep, width); 102 memcpy(*basep, obj, width);
109 return(0); 103 return(0);
110 }; 104 };
111 105
@@ -119,7 +113,7 @@ bindle_badd(
119 dst = ((char *)*basep) + (width * (size_t)idx); 113 dst = ((char *)*basep) + (width * (size_t)idx);
120 if ((freeobj)) 114 if ((freeobj))
121 (*freeobj)(dst); 115 (*freeobj)(dst);
122 bindle_array_move(obj, dst, width); 116 memcpy(dst, obj, width);
123 return(idx); 117 return(idx);
124 }; 118 };
125 if ((opts & BNDL_ARRAY_MASK_ADD) != BNDL_ARRAY_MERGE) 119 if ((opts & BNDL_ARRAY_MASK_ADD) != BNDL_ARRAY_MERGE)
@@ -140,12 +134,12 @@ bindle_badd(
140 { 134 {
141 src = ((char *)*basep) + (width * (size_t)(pos+0)); 135 src = ((char *)*basep) + (width * (size_t)(pos+0));
142 dst = ((char *)*basep) + (width * (size_t)(pos+1)); 136 dst = ((char *)*basep) + (width * (size_t)(pos+1));
143 bindle_array_move(src, dst, width); 137 memcpy(dst, src, width);
144 }; 138 };
145 139
146 // save object 140 // save object
147 dst = ((char *)*basep) + (width * wouldbe); 141 dst = ((char *)*basep) + (width * wouldbe);
148 bindle_array_move(obj, dst, width); 142 memcpy(dst, obj, width);
149 143
150 // increment nelp 144 // increment nelp
151 (*nelp)++; 145 (*nelp)++;
@@ -174,24 +168,6 @@ bindle_bsearch(
174} 168}
175 169
176 170
177void
178bindle_array_move(
179 void * a,
180 void * b,
181 size_t size )
182{
183 uint8_t * x;
184 uint8_t * y;
185 size_t s;
186 BindleDebugTrace();
187 x = a;
188 y = b;
189 for(s = size; (s > 0); s--)
190 *y++ = *x++;
191 return;
192}
193
194
195ssize_t 171ssize_t
196bindle_bremove( 172bindle_bremove(
197 const void * key, 173 const void * key,
@@ -233,7 +209,7 @@ bindle_bremove(
233 { 209 {
234 src = ((char *)base) + (width * (size_t)(pos+1)); 210 src = ((char *)base) + (width * (size_t)(pos+1));
235 dst = ((char *)base) + (width * (size_t)(pos+0)); 211 dst = ((char *)base) + (width * (size_t)(pos+0));
236 bindle_array_move(src, dst, width); 212 memcpy(dst, src, width);
237 }; 213 };
238 214
239 return(0); 215 return(0);
@@ -389,11 +365,11 @@ bindle_enqueue(
389 { 365 {
390 src = ((char *)*basep) + (width * (size_t)(pos-1)); 366 src = ((char *)*basep) + (width * (size_t)(pos-1));
391 dst = ((char *)*basep) + (width * (size_t)(pos-0)); 367 dst = ((char *)*basep) + (width * (size_t)(pos-0));
392 bindle_array_move(src, dst, width); 368 memcpy(dst, src, width);
393 }; 369 };
394 370
395 // save object 371 // save object
396 bindle_array_move(obj, ((char *)*basep), width); 372 memcpy(((char *)*basep), obj, width);
397 373
398 // increment nel 374 // increment nel
399 (*nelp)++; 375 (*nelp)++;
@@ -463,7 +439,7 @@ bindle_push(
463 439
464 // save object 440 // save object
465 ptr = ((char *)*basep) + (width * (*nelp)); 441 ptr = ((char *)*basep) + (width * (*nelp));
466 bindle_array_move(obj, ptr, width); 442 memcpy(ptr, obj, width);
467 443
468 // increment nel 444 // increment nel
469 (*nelp)++; 445 (*nelp)++;