Hi,
I'm trying to assign variables where vpSec0 points. -
void * vpSec0 = NULL;
-
CreateHVFESection0(vpSec0);
-
CreateHVFESecti on0 function is below. -
void CreateHVFESection0(void * vpSec0)
-
{
-
int hSec0;
-
size_t * nbytes = (size_t *) malloc(sizeof(size_t));
-
hSec0 = bitio_o_open();
-
-
/* 'B','U','F','R' */
-
bitio_o_append(hSec0,66,8);
-
bitio_o_append(hSec0,85,8);
-
bitio_o_append(hSec0,70,8);
-
bitio_o_append(hSec0,82,8);
-
-
/* Total length of BUFR message in bytes */
-
bitio_o_append(hSec0,0,24);
-
-
/* BUFR Edition Number = 4 */
-
bitio_o_append(hSec0,4,8);
-
vpSec0 = bitio_o_close(hSec0, nbytes);
-
-
free(nbytes);
-
nbytes = NULL;
-
-
-
}
-
CreateHVFESecti on0 uses some other functions. But I think the problem is here: - vpSec0 = bitio_o_close(hSec0, nbytes);
because i run the program with gdb debugger. Before coming here, vpSec0 is 0x0, means NULL. Everything is normal to here. -
void *bitio_o_close (handle, nbytes)
-
-
int handle;
-
size_t *nbytes;
-
-
/* This function closes a output-bitstream identified by HANDLE and returns
-
a pointer to the memory-area holding the bit-stream.
-
-
parameters:
-
HANDLE: Bit-stream-handle
-
NBYTES: number of bytes in the bitstream.
-
-
The funcion returns a pointer to the memory-area holding the bit-stream or
-
NULL if an invalid handle was specified. The memory area must be freed by
-
the calling function.
-
*/
-
-
{
-
-
if (!bios[handle].used) return NULL;
-
-
/******* Fill up the last byte with 0-bits */
-
-
while (bios[handle].nbits % 8 != 0) bitio_o_append (handle, 0, 1);
-
-
*nbytes = (size_t) ((bios[handle].nbits - 1) / 8 + 1);
-
bios[handle].used = 0;
-
return (void *) bios[handle].buf;
-
}
-
void *bitio_o_close (handle, nbytes)
-
-
int handle;
-
size_t *nbytes;
-
-
/* This function closes a output-bitstream identified by HANDLE and returns
-
a pointer to the memory-area holding the bit-stream.
-
-
parameters:
-
HANDLE: Bit-stream-handle
-
NBYTES: number of bytes in the bitstream.
-
-
The funcion returns a pointer to the memory-area holding the bit-stream or
-
NULL if an invalid handle was specified. The memory area must be freed by
-
the calling function.
-
*/
-
-
{
-
-
if (!bios[handle].used) return NULL;
-
-
/******* Fill up the last byte with 0-bits */
-
-
while (bios[handle].nbits % 8 != 0) bitio_o_append (handle, 0, 1);
-
-
*nbytes = (size_t) ((bios[handle].nbits - 1) / 8 + 1);
-
bios[handle].used = 0;
-
return (void *) bios[handle].buf;
-
}
-
-
when i step into bitio_o_close function, before - return (void *) bios[handle].buf
, the address of bios[handle].buf is 0x2a99700930. So we expect that after returning, vpSec0's address will also be 0x2a99700930. But after returning when i print vpSec0, it's address seems 0xffffffff99700 930, and this is out of bounds which falls me in Segmentation faults further in my program.
Please help.
Thanx.
1 2349
Part of your problem is right here:
void CreateHVFESecti on0(void * vpSec0)
{
etc...
Inside this function vpSec0 is a copy of the vpSec0 used to make the call.
C has only call by value so function arguments are always copies of the variables used to call the funciton.
To change the address in the vpSec0 used on the call you need to pass the address of the pointer: -
void CreateHVFESection0(void ** vpSec0)
-
{
-
etc...
-
Then inside CreateHVFESecti on0() you change the caller's pointer by: -
*vpSec0 = bitio_o_close(hSec0, nbytes);
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Randy Jackson |
last post by:
I'm attempting to debug some code that uses the System function. When the
function is called, it returns Error 1. Does anyone know what that error
might be, or where I can find a list of error codes for the function?
Any help is most appreciated.
--
Randy Jackson
http://fourcolorexplosion.com
|
by: Steven T. Hatton |
last post by:
If I do:
typedef vector<size_t> v_T;
pair<v_T, v_T> b_T;
b_T bounds(v_T(n), v_T(n)); // if that doesn't work
// std::make_pair(v_T(n), v_T(n));
b_T diff_v(n);
void populate_bounds(&bounds); // all bounds.first <= bounds.second
|
by: dharmadam |
last post by:
Is it possible to pass a column name or the order of the column name
in the DB2 table table function. For example, I want to update the
address of a person by passing one of the address column name like ZIP
CODE or ADDRESS LINE. I will call the function with three
parameter--UpdateAddress(5,zip_code,person_id) where 5 indicates
ZIP_CODE is the fifth column in the table. If 4 is passed, it
indicates the address line is to be updated.
...
|
by: Ravindranath Gummadidala |
last post by:
Hi All:
I am trying to understand the C function call mechanism. Please bear with
me as I state what I know:
"every invocation of a function causes a frame for that function to be
pushed on stack. this contains the arguments this function was called
with, address to return to after return from this function (the location
in the previous stack frame), location of previous frame on stack (base or
start of this frame) and local variables...
|
by: anonymous |
last post by:
Thanks your reply.
The article I read is from
www.hakin9.org/en/attachments/stackoverflow_en.pdf.
And you're right. I don't know it very clearly. And that's why I want
to understand it; for it's useful to help me to solve some basic
problem which I may not perceive before.
I appreciate your help,
sincerely.
| |
by: I.M. !Knuth |
last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until
I started goofing around with this:
================================================================================
/* A function that returns a pointer-of-arrays to the calling function. */
#include <stdio.h>
int *pfunc(void);
|
by: Travis |
last post by:
I am using a function that returns a const char * that is usually a
word, etc. How can I check to see if what it returns is empty?
I tried if (function() == "") and (function() == NULL) and (function()
== '/0').
But then I see that the those if statements are flagging true when the
function returns back a char * or no length
|
by: sam.barker0 |
last post by:
Hi ,
I am having 3 functions.When I step through when func b returns to
funca.it throws an error "cannot find function bounds"
funca()
{
....
...
funcb();
}
|
by: e2point |
last post by:
hi,
i got a program that is suppose to run 24x7x365. However after
functioning for around 15 minutes, it crashes due to a segmentation
fault. program is written in c++ and runs in RH Linux 4. When
inspected one of the parameters of the crashing frame, i get the
following output.
NOTE : c1 is a std::vector
(gdb) pvector c1
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |