Mercurial > hg > xemacs-beta
diff src/dynarr.c @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | fdefd0186b75 |
children | e38acbeb1cae |
line wrap: on
line diff
--- a/src/dynarr.c Fri Mar 08 13:33:14 2002 +0000 +++ b/src/dynarr.c Wed Mar 13 08:54:06 2002 +0000 @@ -1,5 +1,6 @@ /* Simple 'n' stupid dynamic-array module. Copyright (C) 1993 Sun Microsystems, Inc. + Copyright (C) 2002 Ben Wing. This file is part of XEmacs. @@ -65,15 +66,32 @@ Dynarr_add_many(d, base, len) [MACRO] Add LEN elements to the end of the dynamic array. The elements - should be contiguous in memory, starting at BASE. + should be contiguous in memory, starting at BASE. If BASE if NULL, + just make space for the elements; don't actually add them. Dynarr_insert_many_at_start(d, base, len) [MACRO] Append LEN elements to the beginning of the dynamic array. The elements should be contiguous in memory, starting at BASE. + If BASE if NULL, just make space for the elements; don't actually + add them. Dynarr_insert_many(d, base, len, start) Insert LEN elements to the dynamic array starting at position START. The elements should be contiguous in memory, starting at BASE. + If BASE if NULL, just make space for the elements; don't actually + add them. + + Dynarr_delete(d, i) + [MACRO] Delete an element from the dynamic array at position I. + + Dynarr_delete_many(d, start, len) + Delete LEN elements from the dynamic array starting at position + START. + + Dynarr_delete_by_pointer(d, p) + [MACRO] Delete an element from the dynamic array at pointer P, + which must point within the block of memory that stores the data. + P should be obtained using Dynarr_atp(). int Dynarr_length(d) [MACRO] Return the number of elements currently in a dynamic array. @@ -116,7 +134,7 @@ if (DUMPEDP (dy->base)) { void *new_base = malloc (new_size); - memcpy (new_base, dy->base, dy->max > new_size ? new_size : dy->max); + memcpy (new_base, dy->base, dy->max > new_size ? dy->max : new_size); dy->base = new_base; } else @@ -174,7 +192,8 @@ (char *) dy->base + start*dy->elsize, (dy->cur - start)*dy->elsize); } - memcpy ((char *) dy->base + start*dy->elsize, el, len*dy->elsize); + if (el) + memcpy ((char *) dy->base + start*dy->elsize, el, len*dy->elsize); dy->cur += len; if (dy->cur > dy->largest)