473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

help on free() for huge pointer

2
typedef struct FileHdr
{
unsigned long reg;
unsigned short width;
float sfactor;
struct FileHdr huge *next;
}FileHdr;
FileHdr huge *Hdrhead=NULL,huge *Hdrcur=NULL;
//
//
Hdrhead=(FileHdr huge *)malloc(sizeof(FileHdr));
//some operation
free(Hdrhead);

when i try to free huge pointer i get a warning stating suspicious pointer conversion
is there any other best way to free huge pointer
Nov 4 '08 #1
5 1658
arnaudk
424 256MB
The name of your struct and the typedef are the same.
Nov 4 '08 #2
cpdar
2
The name of your struct and the typedef are the same.
I hope that is allowed, i can do all the operation that i want to, but i am not finding way to release used memory (huge pointer).
Nov 4 '08 #3
arnaudk
424 256MB
In:

struct FileHdr huge *next;

What does "next" point to? As far as I can tell, struct FileHdr is the type specifier, so what is "huge"? Also, watch out when you delete the pointer to FileHdr as it looks like you could loose the pointer to the next FileHdr (Hdrhead->next) so its memory can never be freed.
Nov 4 '08 #4
Banfa
9,065 Expert Mod 8TB
The problem is that you are passing a huge pointer to free

For those that don't know some platforms allow specifying pointer semantics relevant to the memory model in use. the huge indicates the type of pointer and where it can point. huge was memory model available in 16 bit Windows (WIN16, Windows 3.1x and earlier).

That is the suspicious conversion, an implicit cast away of the huge pointer semantics.

You don't get an error on cast void * to void huge *, when mallocing, because that is a valid conversion, any void * can be represented by a void huge * but not any void huge * can be represented by a void * hence the error when calling free.

Because malloc returns void * use of the huge pointer semantics is pointless you could just as well remove all those voids and the code should still work (and be more portable).

What platform are you using?
Nov 4 '08 #5
arnaudk
424 256MB
For those that don't know some platforms allow specifying pointer semantics relevant to the memory model in use. the huge indicates the type of pointer and where it can point. huge was memory model available in 16 bit Windows (WIN16, Windows 3.1x and earlier).
Interesting, that's why I didn't find it in my Stroustrup...
PS: I see now that near, far and huge pointers date back to the pre-i386 days.
Nov 4 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
2
by: J. Nielsen | last post by:
I'm not a programmer and I don't have the time and energy to start learning right now So I need some help. Let's say I have made an HTML Table (consisting of three columns and six rows). In each...
13
by: na1paj | last post by:
here's a simple linked list program. the DeleteNode function is producing an infinit loop i think, but i can't figure out where.. #include <stdio.h> typedef struct { char *str; //str is a...
16
by: David Ford | last post by:
I have a macro that I use across the board for freeing ram. I'd like to clean up my code so I don't get these warnings. #define sfree(x) _internal_sfree((void **)&x) #define _internal_sfree(x)...
5
by: skumar434 | last post by:
Hi everybody, I am faceing problem with strings. The code is given bellow .In this program i am tring to copy data from a file into structure . I am able to copy the data ,but the dat is...
171
by: Raman | last post by:
Hi All, Here is a small Code, int main(void) { char *p=(char *) malloc(100); strcpy(p,"Test1234567890"); p=p+10; free(p);
5
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I...
3
by: Chris AtLee | last post by:
Sorry for the repeat post...I'm not sure if my first post (on May 30th) went through or not. I've been trying to write a PAM module using ctypes. In the conversation function (my_conv in the...
30
by: Alf P. Steinbach | last post by:
I once suggested in that SomeOne Else(TM) should propose a string value class that accepted literals and char pointers and so on, with possible custom deleter, and in case of literal strings just...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.