Sponsored Content
Full Discussion: double pointer usage
Top Forums Programming double pointer usage Post 302095196 by axes on Saturday 4th of November 2006 08:50:37 AM
Old 11-04-2006
double pointer usage

Hi,

Is there anything wrong in the following code : - Because I am freeing the local variable tt, will it affect 'str' variable in the main function. will there be any memory leaks for bulk requests?

Thanks in advance

main(){
char *str="hi";
fun(&str);
printf("str=%s\n",str);
}
fun(char **str){
char *tt;
tt=(char *)malloc(sizeof("hello"));
strcpy(tt,"hello");
tt=(char *)realloc(tt,sizeof("hello world"));
strcpy(tt,"hello world");
*str=tt;
free(tt);
}
axes
 

10 More Discussions You Might Find Interesting

1. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies

2. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

3. Programming

Pointer to a struct (with pointers) *** glibc detected *** double free

I am using a structure defined as follows struct gene_square { double *x; double *y; };I have class, with a member function which is a pointer of this type: gene_square* m_Genes;I am allocating memory in the constructors like this: m_Genes = new gene_square; for (ii=0;... (1 Reply)
Discussion started by: jatoo
1 Replies

4. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

5. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

6. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

7. Shell Programming and Scripting

Confused with the usage of one variable usage

Hi All I am not able to understand the usage of d# in the below variable declaration. FILE_LOC contains the directory path And also help me to know about what will be saved in the variable j. Thanks!!! j=${d#${FILE_LOC}/} (2 Replies)
Discussion started by: mohanm
2 Replies

8. UNIX for Dummies Questions & Answers

Command to display the space usage (memory usage) of a specific directory.

Hi all, Can you please tell me the command, with which one can know the amount of space a specific directory has used. df -k . ---> Displays, the amount of space allocated, and used for a directory. du -k <dir name> - gives me the memory used of all the files inside <dir> But i... (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

9. Programming

double pointer allocation

hi guys how can I allocate a double char pointer? I want an array of pointers to char objects. the objects the double pointer points to are : char b; (1 Reply)
Discussion started by: vlm
1 Replies

10. UNIX for Dummies Questions & Answers

Memory usage per user,percent usage,sytem time in ksh

Let's say i have 20 users logged on Server. How can I know how much memory percent used each of them is using with system time in each user? (2 Replies)
Discussion started by: roy1912
2 Replies
create_sub_bitmap(3alleg4)					  Allegro manual					create_sub_bitmap(3alleg4)

NAME
create_sub_bitmap - Creates a memory sub bitmap. Allegro game programming library. SYNOPSIS
#include <allegro.h> BITMAP *create_sub_bitmap(BITMAP *parent, int x, y, width, height); DESCRIPTION
Creates a sub-bitmap, ie. a bitmap sharing drawing memory with a pre-existing bitmap, but possibly with a different size and clipping set- tings. When creating a sub-bitmap of the mode-X screen, the x position must be a multiple of four. The sub-bitmap width and height can extend beyond the right and bottom edges of the parent (they will be clipped), but the origin point must lie within the parent region. RETURN VALUE
Returns a pointer to the created sub bitmap, or NULL if the sub bitmap could not be created. Remember to free the sub bitmap before freeing the parent bitmap to avoid memory leaks and potential crashes accessing memory which has been freed. SEE ALSO
create_bitmap(3alleg4), create_bitmap_ex(3alleg4), destroy_bitmap(3alleg4), is_sub_bitmap(3alleg4), clear_bitmap(3alleg4), clear_to_color(3alleg4), expat(3alleg4), exscroll(3alleg4), exswitch(3alleg4) Allegro version 4.4.2 create_sub_bitmap(3alleg4)
All times are GMT -4. The time now is 04:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy