🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #2208

malloc (...) in gcc+emx

#2208
From: Johannes Maehner
Date: Wed, 30 Sep 1992 17:38
28 lines
1399 bytes
I've got the gcc2.2.2+emx0.8e programming environment for OS/2 2.0.
Consider the following C-program:
   
    #include <stdio.h>
    #include <malloc.h>

    void main ()
    {
       char *buf = (char *) malloc (<size>);

       if (buf != NULL) printf ("memory allocated\n");
       else printf ("allocation failed\n");
       free (buf);
    } 

The behavior of the program:
If <size> gets too high (of course, <size> 
is in a valid integer range and >= 0) malloc doesn't return a 
NULL - pointer but the program turns in a core-dump
(gdb says that the program received signal 11, segmentation-fault)

Can YOU tell me how to solve the problem?
(I guess malloc gets in conflict with the
 memory protection of OS/2 2.0 but doesn't recognize 
 it as an error) 
Is there a way to use the virtual memory management
when allocating store on the heap?
Technical Details
Message-ID: <1992Sep30.173840.17721@Informatik.TU-Muenchen.DE>
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!Sirius.dfn.de!fauern!LRZnews!informatik.tu-muenchen.de!maehner

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!Sirius.dfn.de!fauern!LRZnews!informatik.tu-muenchen.de!maehner
From: maehner@Informatik.TU-Muenchen.DE (Johannes Maehner)
Subject: malloc (...) in gcc+emx
Originator: maehner@hphalle3a.informatik.tu-muenchen.de
Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem)
Organization: Technische Universitaet Muenchen, Germany
Date: Wed, 30 Sep 1992 17:38:40 GMT
Message-ID: <1992Sep30.173840.17721@Informatik.TU-Muenchen.DE>
Lines: 31