array_length(3) Library Functions Manual array_length(3)NAME
array_length - get number of allocated members in array
SYNTAX
#include <array.h>
int64 array_length(array* x,uint64 membersize);
array x;
int64 members = array_length(&x,sizeof(t));
DESCRIPTION
array_length returns the number of initialized bytes in x, divided by the size of t. In other words, array_get will succeed for positions 0
through array_length-1; it will fail for position array_length.
If x is unallocated, array_length and array_bytes return 0.
SEE ALSO array_allocate(3), array_get(3), array_fail(3), array_bytes(3)array_length(3)
Check Out this Related Man Page
array(3) Library Functions Manual array(3)NAME
array - The array library interface
SYNTAX
#include <array.h>
DESCRIPTION
An allocated array variable keeps track of
o a (nonzero) pointer to a dynamically allocated region of memory;
o the number of bytes allocated (always positive); and
o the number of bytes initialized (between 0 and the number of bytes allocated).
There are two other possibilities for the state of an array variable: unallocated and failed. In both cases, there is no dynamically allo-
cated region of memory.
A new array variable is normally created as a static variable:
#include "array.h"
static array x;
At this point it is unallocated. The array library provides various allocation and inspection functions.
A new array variable can also be created dynamically. It must be initialized to all-0, meaning unallocated, before it is given to any of
the array functions. It must be returned to the unallocated (or failed) state, for example with array_reset, before it is destroyed. These
rules prevent all memory leaks.
Expansion and inspection
array x;
t* p1 = array_allocate(&x,sizeof(t),pos);
t* p2 = array_get(&x,sizeof(t),pos);
t* p3 = array_start(&x);
int64 len = array_length(&x,sizeof(t));
int64 bytes = array_bytes(&x);
Truncation and deallocation
array x;
array_truncate(&x,sizeof(t),len);
array_trunc(&x);
array_reset(&x);
array_fail(&x);
Comparison
array x;
array y;
if (array_equal(&x,&y))
/* arrays are equal... */
Concatenation
array x;
array y;
array_cat(&x,&y);
array_catb(&x,"fnord",5);
array_cats(&x,"fnord");
array_cats0(&x,"fnord"); /* also append the */
array_cat0(&x); /* append */
array_cate(&x,"fnord",1,4); /* append "nor" */
ORIGINAL API DEFINITION
http://cr.yp.to/lib/array.html
SEE ALSO array_get(3), array_start(3), array_fail(3)array(3)
I need to implement the following logic and need some expert help from UNIX community.
These are the steps in my Shell script.
1. Analyze a file.
2. Extract all the ID's in that file.
3. Use the ID's from #2 to run another filter on the file.
I've implemented # 1 and 2 using... (3 Replies)
Hello All,
I have this script that does stuff like "starting, stopping & restarting" a Daemon Process running on my machine...
My main question is why in part of my code (which you will see below) does the Array Length (i.e. ${#PIDS} )
return "1" when I know the Array is empty..?
Here is... (17 Replies)
Hello;
When I wrote a function to print out an array,
void p_array(int arr)
{
int i;
int size = sizeof(arr) / sizeof(int);
// int size = sizeof (arr) / sizeof (arr);
for (i = 0; i < size; i++)
printf("%d ", arr);
printf("\n");
}I could only print out the... (19 Replies)
Hi there,
I'm listing files and sorting them. When I try to get length of array variable in which these files are stored I get 1 as value. That's weird.
files_info="$(find $input_dir -name "*_CHR$i.info" | sort )"
printf ${#files_info}"\n" #print length
#--loop through... (6 Replies)