Sponsored Content
Full Discussion: malloc
Top Forums Programming malloc Post 27866 by rajashekaran on Monday 9th of September 2002 04:30:28 AM
Old 09-09-2002
malloc

hello sir

since by mentioning a integer pointer and storing the integers
by incrementing the pointer value
then what is the purpose of malloc?
u can decalre it as
in t *p;
several integers can be stored by incrementing the value of p,
hence what is the diffrence between this declaration and
malloc function.
this is an basic question according to my knowledge.
please answer this.
 

10 More Discussions You Might Find Interesting

1. Programming

a problem about malloc()

1 . Thanks everyone who read the post. 2 . the programe is that : #include <stdio.h> #include <string.h> void do_it(char *p) { p = (char *) malloc(100); (void )strcpy(p,"1234"); } int main(void) { char *p; do_it(p); (void )printf("p = %s \n",p); (1 Reply)
Discussion started by: chenhao_no1
1 Replies

2. Programming

When to use Malloc?

Hi! I hope this is the correct forum to post the question even if I'm a newbie... I am a C-newbie (and really on the edge to be a C-addict ;) ) and have a question. When should I use malloc? To state it differently, when should I NOT use malloc? For instance, if I have an array of... (5 Replies)
Discussion started by: Tonje
5 Replies

3. Programming

malloc()

Some one please explain me what is Dynamic memory allocation and the use of malloc() function.How do we allocate memory dynamically and also the other way? (3 Replies)
Discussion started by: rash123
3 Replies

4. Programming

Malloc implementation in C

Hey Guys I am trying to implement the malloc function for my OS class and I am having a little trouble with it. I would be really grateful if I could get some hints on this problem. So I am using a doubly-linked list as my data structure and I have to allocate memory for it (duh...). The... (1 Reply)
Discussion started by: Gambit_b
1 Replies

5. UNIX for Advanced & Expert Users

Malloc Implementation in C

Hey Guys Some of my friends have got together and we are trying to write a basic kernel similar to Linux. I am trying to implement the malloc function in C and I am using a doubly linked list as the primary data structure. I need to allocate memory for this link list (duh...) and I don't feel... (2 Replies)
Discussion started by: rbansal2
2 Replies

6. Programming

malloc vs realloc

Why when using realloc, john is reversed 3 times but not the other 2 names ? But if I use malloc, then the 3 names are reversed correctly ? (but then there is a memory leak) How can I reverse all 3 names without a memory leak ? char *BUFFER = NULL; char *STRREVERSE(const char *STRING) {... (5 Replies)
Discussion started by: cyler
5 Replies

7. UNIX for Dummies Questions & Answers

Kmalloc and malloc

Do kmalloc and malloc allocate from same heap ? (3 Replies)
Discussion started by: dragonpoint
3 Replies

8. Programming

help with malloc [solved]

Hi i found code in google how to malloc an 2D array and i tried that : #include<stdio.h> #include<stdlib.h> int **A; int **B; int main(int argc,char *argv) { printf("name of text : %s\n",argv); //read arrays int i,j; int l,m; int M,n; FILE *fp; fp=fopen(argv,"r"); ... (0 Replies)
Discussion started by: giampoul
0 Replies

9. Programming

malloc vs new speed

Which one is faster among malloc and new? My understanding is that since new also has to call constructors after allocating memory it must be slower than malloc. Am I correct? (1 Reply)
Discussion started by: rupeshkp728
1 Replies

10. UNIX for Dummies Questions & Answers

Help with malloc()

Good day! I'm a newbie in C. I'm trying to get an unlimited input from the user using malloc then printing the inputs after the user presses enter. My code works, but there's a warning that I don't know how to fix. Please help me. Thank you. Here's my code: #include <stdio.h> #include... (6 Replies)
Discussion started by: eracav
6 Replies
xdr_simple(3N)															    xdr_simple(3N)

NAME
xdr_simple, xdr_bool, xdr_char, xdr_double, xdr_enum, xdr_float, xdr_free, xdr_hyper, xdr_int, xdr_long, xdr_longlong_t, xdr_quadruple, xdr_short, xdr_u_char, xdr_u_hyper, xdr_u_int, xdr_u_long, xdr_u_longlong_t, xdr_u_short, xdr_void - library routines for external data representation SYNOPSIS
DESCRIPTION
XDR library routines allow C programmers to describe simple data structures in a machine-independent fashion. Protocols such as remote procedure calls (RPC) use these routines to describe the format of the data. These routines require the creation of XDR streams (see xdr_create(3N)). Routines See rpc(3N) for the definition of the data structure. Note that any buffers passed to the XDR routines must be properly aligned. It is suggested that malloc(3C) be used to allocate these buffers or that the programmer insure that the buffer address is divisible evenly by four. translates between booleans (C integers) and their external representations. When encoding data, this filter produces values of either or This routine returns if it suc- ceeds, otherwise. translates between C characters and their external representations. This routine returns if it succeeds, otherwise. Note: encoded characters are not packed, and occupy 4 bytes each. For arrays of characters, it is worthwhile to consider or (see xdr_complex(3N)). translates between C precision numbers and their external representations. This routine returns if it succeeds, otherwise. translates between C (actually integers) and their external representations. This routine returns if it succeeds, otherwise. translates between C and their external representations. This routine returns if it succeeds, otherwise. Generic freeing routine. The first argument is the XDR routine for the object being freed. The second argument is a pointer to the object itself. Note: the pointer passed to this routine is not freed, but what it points to is freed (recursively, depending on the XDR routine). translates between ANSI C integers and their external representations. This routine returns if it succeeds, otherwise. translates between C integers and their external representations. This routine returns if it succeeds, otherwise. translates between C integers and their external representations. This routine returns if it succeeds, otherwise. translates between ANSI C integers and their external representations. This routine returns if it succeeds, otherwise. This routine is identical to translates between IEEE quadruple precision floating point numbers and their external representations. This routine returns if it succeeds, otherwise. translates between C integers and their external representations. This routine returns if it succeeds, otherwise. translates between C characters and their external representations. This routine returns if it succeeds, otherwise. translates between unsigned ANSI C integers and their external representations. This routine returns if it succeeds, otherwise. A filter primitive that translates between a C integer and its external representation. This routine returns if it succeeds, otherwise. translates between C integers and their external representations. This routine returns if it succeeds, otherwise. translates between unsigned ANSI C integers and their external representations. This routine returns if it succeeds, otherwise. This routine is identical to translates between C integers and their external representations. This routine returns if it succeeds, otherwise. This routine always returns It may be passed to RPC routines that require a function parameter, where nothing is to be done. MULTITHREAD USAGE
Thread Safe: Yes Cancel Safe: Yes Fork Safe: No Async-cancel Safe: No Async-signal Safe: No These functions can be called safely in a multithreaded environment. They may be cancellation points in that they call functions that are cancel points. In a multithreaded environment, these functions are not safe to be called by a child process after and before These functions should not be called by a multithreaded application that support asynchronous cancellation or asynchronous signals. SEE ALSO
malloc(3C), rpc(3N), xdr_admin(3N), xdr_complex(3N), xdr_create(3N). xdr_simple(3N)
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy