Sponsored Content
Full Discussion: Dynamic memory allocation
Top Forums Programming Dynamic memory allocation Post 302231456 by shamrock on Tuesday 2nd of September 2008 10:40:53 AM
Old 09-02-2008
Quote:
Originally Posted by naan
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 with the size of the line?


Is there any optimised way to do this?

Thanks,
Anitha
Any compelling reason to go for a dynamic solution??
A static solution may not be optimized but a dynamic solution would be expensive in terms of mp units.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

memory allocation

I would like to know how I could allocate some more memory to a process. Please note that I am not the root user. (1 Reply)
Discussion started by: sagar
1 Replies

2. Programming

array dynamic allocation

Hi, I have the following problem: i must allocate a dynamic array from a subroutine which should return such array to main function. The subroutine has already a return parameter so i thought of pass the array as I/O parameter. I tried the following program but it doesn't work (segmentation... (11 Replies)
Discussion started by: littleboyblu
11 Replies

3. Programming

Memory allocation problem

I have a program that will fetch some particular lines and store it in a buffer for further operations.The code which is given below works but with some errors.I couldn't trace out the error.Can anybody help on this plz?? #include <stdio.h> #include <stdlib.h> #include<string.h> #define... (1 Reply)
Discussion started by: vigneshinbox
1 Replies

4. Programming

global variables and dynamic allocation

Hi, is it possible in C to allocate dynamically a global variable?? (3 Replies)
Discussion started by: littleboyblu
3 Replies

5. Programming

Is there a problem with the memory allocation???

I have a scenario like the client has to search for the active server.There will be many servers.But not all server are active.And at a time not more than one server will be active. The client will be in active state always i.e, it should always search for an active server until it gets one.I... (1 Reply)
Discussion started by: vigneshinbox
1 Replies

6. Programming

dynamic allocation vs static allocation in c

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

7. Programming

Memory allocation in C

Hi Experts I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables. First: int x; char a; printf("%u %u\n', &x, a); I got the addresses displayed... (2 Replies)
Discussion started by: unx_freak
2 Replies

8. Programming

Dynamic Memory Allocation

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

9. Shell Programming and Scripting

memory allocation to a variable

hello all.. i'm a beginner in shell scripting. I need to know what is really happening when we are creating a variable in shell scripting? how memory is allocated for that variable? (3 Replies)
Discussion started by: aarathy
3 Replies

10. Programming

C++/ROOT Memory Allocation?

Hello, I am new to C++ programming, so I'm still getting a feel for things. I recently wrote a simple C++ program (to be used as a ROOT Macro) to conduct a statistical analysis of a varied version of the Monty Hall problem (code below). Basically, the programs runs a few simple calculations to... (7 Replies)
Discussion started by: Tyler_92
7 Replies
FREEZEGROUP(3PVM)						  PVM Version 3.4						 FREEZEGROUP(3PVM)

NAME
pvm_freezegroup - Freezes dynamic group membership and caches info locally SYNOPSIS
C int info = pvm_freezegroup( char *group , int size) Fortran call pvmffreezegroup( group, size, info ) PARAMETERS
group Character string group name of an existing group. size Size of the group when it is frozen info size of group on success. Values less than 0 indicate and error. DESCRIPTION
The routine pvm_freezegroup makes a dynamic group named group static. The group information is then "cached" by all group members. pvm_freezegroup is a synchronizing routine and must be called by all group members to complete. size indicates the size the dynamic group should be when made static. A value of -1 indicates that the current size of the group should be used. info returns error information. Once a dynamic group has been frozen with pvm_freezegroup , all subsequent operations that can be satisfied with local data use the locally held information. For processes that are outside of the group, the first group call, e.g., pvm_bcast(), will cause the static group infor- mation to be copied to the calling process. Subsequent operations then use the local information. Barriers are still arbitrated by the group server. Group members should call pvm_lvgroup to leave the group and free any allocated structures that hold the group information. Processes not in the group may call pvm_lvgroup to free any locally allocated structures. In this case, an error code of PvmNotInGroup or PvmNoGroup will be returned to the caller. Barrier are always arbitrated by the group server, even if the group has been made static with pvm_freezegroup. If a process leaves a static group while other process are waiting at a barrier, then PvmNoGroup is returned to all processes waiting at the barrier. Future barrier calls with the defunct static group, return the same error. EXAMPLES
C: inum = pvm_joingroup("worker"); info = pvm_freezegroup( "worker", size ); Fortran: CALL PVMFJOINGROUP('group2', inum) CALL PVMFFREEZEGROUP( 'group2', size, info ) ERRORS
These error conditions can be returned by pvm_freezegroup PvmSysErr pvmd was not started or has crashed. PvmBadParam giving a NULL group name. PvmDupGroup trying to freeze a group that is already frozen. PvmNotInGroup trying to freeze a group that you are not in. BUGS
There is no way to unfreeze a group. Processes are not notified if a frozen group becomes invalid. Having a non-member process call pvm_lvgroup to free structures is a bit strange. SEE ALSO
pvm_barrier(3PVM), pvm_lvgroup(3PVM) 16 March 1995 FREEZEGROUP(3PVM)
All times are GMT -4. The time now is 03:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy