11-06-2008
Most variables in C are on the stack - anyway -- regardless,
&variable_name returns the address of the variable itself. If it is a pointer then the contents of memory at that location refer to the start of the data.
If you are messing around with heap and your program calls malloc, be careful. Most malloc implementations set aside metadata areas in heap. You mess with these and you core dump. For example Doug Lea's malloc originally had what amounts to a descriptor
for each malloc call - a pointer to the start of data storage and a 32 bit word that is length of data.
10 More Discussions You Might Find Interesting
1. Programming
Hey,
I want to access oracle database through Unix C programming.. Can you through me some light on that... (5 Replies)
Discussion started by: kavi
5 Replies
2. Shell Programming and Scripting
hi
I wanted to access the C program variables in shell script.
This script is called from the same C program.
What are the ways in which i can access variables
thankx (3 Replies)
Discussion started by: bhakti
3 Replies
3. Programming
Is there a way to find the address of stack memory writing a program? Please guide me (12 Replies)
Discussion started by: jacques83
12 Replies
4. Programming
I have read a number of references to libraries that could be linked into a C program to access various databases. I have been tasked with writing an oracle library that would be able to access an Microsoft access database. The oracle database is running on a Unix server and would have to access... (2 Replies)
Discussion started by: beilstwh
2 Replies
5. Filesystems, Disks and Memory
I'm on solaris 8. I need to check the stack trace inside my C program. I don't have printstack or walkstack. I tested getcontext and it works. But how do I get the symbols from "stack_t" ? Help please. Many thanks! (4 Replies)
Discussion started by: rydahl
4 Replies
6. Shell Programming and Scripting
Hello,
I was wondering if I have something in my bin dir and I want to access it from another directory to make a change how can I go about it. Thank you. (7 Replies)
Discussion started by: gingburg
7 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I need to install a program on my Centos 5.3 server that will block unauthorized ssh/ftp access attempts. The two features I require is that I should be able to configure the program to block the IP of the intruder after a a certain amount of access attempts and that it should display a... (3 Replies)
Discussion started by: mojoman
3 Replies
8. Programming
I need to know what is the maximum stack size i.e. -Xss my java program is running with.
Is there a way to find that out from inside my java program code and outside of it.
What i am looking for is to read whatever the current set max limit -Xss (stack sie) is for a particular JVM(not... (3 Replies)
Discussion started by: mohtashims
3 Replies
9. Programming
Hi All,
I am new to c programming. I am getting compilation error in the below program. Can somebody help me?
#include<stdio.h>
#include<string.h>
void main()
{
int i=j=0;
char a={'f1',4,'f2','4'};
char count;
for(i=0;i<2;i++)
{
for(j=1;j<=2;j++)
{
... (2 Replies)
Discussion started by: sam_14189
2 Replies
10. Programming
Hi,
I am working in UEFI EDK2 Bios source. We created a platform related new package in the EDK2 source. I find a strange issue with the platform related code we added.
When I did source level debugging I noticed the
local variable in a C function is not getting created in stack when its... (6 Replies)
Discussion started by: Divya R
6 Replies
LEARN ABOUT XFREE86
malloc_get_state
MALLOC_GET_STATE(3) Linux Programmer's Manual MALLOC_GET_STATE(3)
NAME
malloc_get_state, malloc_set_state - record and restore state of malloc implementation
SYNOPSIS
#include <malloc.h>
void* malloc_get_state(void);
int malloc_set_state(void *state);
DESCRIPTION
Note: these function are removed in glibc version 2.25.
The malloc_get_state() function records the current state of all malloc(3) internal bookkeeping variables (but not the actual contents of
the heap or the state of malloc_hook(3) functions pointers). The state is recorded in a system-dependent opaque data structure dynamically
allocated via malloc(3), and a pointer to that data structure is returned as the function result. (It is the caller's responsibility to
free(3) this memory.)
The malloc_set_state() function restores the state of all malloc(3) internal bookkeeping variables to the values recorded in the opaque
data structure pointed to by state.
RETURN VALUE
On success, malloc_get_state() returns a pointer to a newly allocated opaque data structure. On error (for example, memory could not be
allocated for the data structure), malloc_get_state() returns NULL.
On success, malloc_set_state() returns 0. If the implementation detects that state does not point to a correctly formed data structure,
malloc_set_state() returns -1. If the implementation detects that the version of the data structure referred to by state is a more recent
version than this implementation knows about, malloc_set_state() returns -2.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+--------------------+---------------+---------+
|Interface | Attribute | Value |
+--------------------+---------------+---------+
|malloc_get_state(), | Thread safety | MT-Safe |
|malloc_set_state() | | |
+--------------------+---------------+---------+
CONFORMING TO
These functions are GNU extensions.
NOTES
These functions are useful when using this malloc(3) implementation as part of a shared library, and the heap contents are saved/restored
via some other method. This technique is used by GNU Emacs to implement its "dumping" function.
Hook function pointers are never saved or restored by these functions, with two exceptions: if malloc checking (see mallopt(3)) was in use
when malloc_get_state() was called, then malloc_set_state() resets malloc checking hooks if possible; if malloc checking was not in use in
the recorded state, but the caller has requested malloc checking, then the hooks are reset to 0.
SEE ALSO
malloc(3), mallopt(3)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU
2017-09-15 MALLOC_GET_STATE(3)