03-28-2009
Hi Shamrock,
*ptr has already been initialized with address of local variable 'array' as -
*ptr = &array; in statement int **ptr = &array;
ptr(int**) -> array(int*) -> (uninitialized/invalid reference to integer).
ptr = &array;
*ptr (or array) = (int*)calloc(n,sizeof(int)); will initialize array to hold address of allocated memory.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is it possible to create a dynamic array in shell script. I am trying to get the list of logfiles that created that day and put it in a dynamic array. I am not sure about it. help me
New to scripting
Gundu (3 Replies)
Discussion started by: gundu
3 Replies
2. Shell Programming and Scripting
Could one of you, please, provide some input regarding my problem below and it is as follows:
I have 2 files that I need to make sure are identical before processing:
First, I sort both files
Second, I do a diff file1 file2 > File 3
This provides me with the difference.
Now, I need to... (6 Replies)
Discussion started by: ddedic
6 Replies
3. Shell Programming and Scripting
i want to create an array
the array elements are populated depending upon the number of entries present in a data file
The data file is created dynamically
how to achieve the same
thanks (1 Reply)
Discussion started by: trichyselva
1 Replies
4. Programming
Hi,
I am trying to process line by line of a file. But I should not be allocating static allocation for reading the contents of the file. The memory should be dynamically allocated. The confusion here is how do I determine the size of each line, put it into a buffer with the memory allocated... (11 Replies)
Discussion started by: naan
11 Replies
5. Programming
I am facing a strange error while creating posix threads:
Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output.
Snippet 1
This works:
--------------
int *threadids;
threadids = (int *) malloc (num_threads * sizeof(int));
... (4 Replies)
Discussion started by: kmehta
4 Replies
6. Programming
Hi,
is it possible in C to allocate dynamically a global variable?? (3 Replies)
Discussion started by: littleboyblu
3 Replies
7. Programming
i wrote a tiny version of tail command using a large buffer statically allocated but, in a second time, i found another version in which i use a bidimensional array dynamically allocated.
here is the first version
/*my tiny tail, it prints the last 5 line of a file
*/
#include<stdio.h>... (4 Replies)
Discussion started by: lucasclaus
4 Replies
8. Shell Programming and Scripting
Hi,
I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies
9. Shell Programming and Scripting
Hello,
Can somebody please give me a snippet for the below requirement.
I want to assign the values separeted by a comma to be assigned to a dynamic array.
If I give an input (read statement) like abc1,abc2,abc3,abc4,abc5, all these strings abc* should be assigned to an array like below... (2 Replies)
Discussion started by: suneelj
2 Replies
10. Programming
Hello Guys
I have a small confusion in the dynamic memory allocation concept.
If we declare a pointer say a char pointer, we need to allocate adequate memory space.
char* str = (char*)malloc(20*sizeof(char));
str = "This is a string";
But this will also work.
char* str = "This... (2 Replies)
Discussion started by: tene
2 Replies
LEARN ABOUT NETBSD
atomic_dec_64
ATOMIC_DEC(3) BSD Library Functions Manual ATOMIC_DEC(3)
NAME
atomic_dec, atomic_dec_32, atomic_dec_uint, atomic_dec_ulong, atomic_dec_ptr, atomic_dec_64, atomic_dec_32_nv, atomic_dec_uint_nv,
atomic_dec_ulong_nv, atomic_dec_ptr_nv, atomic_dec_64_nv -- atomic decrement operations
SYNOPSIS
#include <sys/atomic.h>
void
atomic_dec_32(volatile uint32_t *ptr);
void
atomic_dec_uint(volatile unsigned int *ptr);
void
atomic_dec_ulong(volatile unsigned long *ptr);
void
atomic_dec_ptr(volatile void *ptr);
void
atomic_dec_64(volatile uint64_t *ptr);
uint32_t
atomic_dec_32_nv(volatile uint32_t *ptr);
unsigned int
atomic_dec_uint_nv(volatile unsigned int *ptr);
unsigned long
atomic_dec_ulong_nv(volatile unsigned long *ptr);
void *
atomic_dec_ptr_nv(volatile void *ptr);
uint64_t
atomic_dec_64_nv(volatile uint64_t *ptr);
DESCRIPTION
The atomic_dec family of functions decrement (by one) the variable referenced by ptr in an atomic fashion.
The *_nv() variants of these functions return the new value.
The 64-bit variants of these functions are available only on platforms that can support atomic 64-bit memory access. Applications can check
for the availability of 64-bit atomic memory operations by testing if the pre-processor macro __HAVE_ATOMIC64_OPS is defined.
SEE ALSO
atomic_ops(3)
HISTORY
The atomic_dec functions first appeared in NetBSD 5.0.
BSD
April 11, 2007 BSD