何となく Blog by Jitta
Microsoft .NET 考

目次

Blog 利用状況
  • 投稿数 - 761
  • 記事 - 18
  • コメント - 35945
  • トラックバック - 222
ニュース
  • IE7以前では、表示がおかしい。div の解釈に問題があるようだ。
    IE8の場合は、「互換」表示を OFF にしてください。
  • 検索エンジンで来られた方へ:
    お望みの情報は見つかりましたか? よろしければ、コメント欄にどのような情報を探していたのか、ご記入ください。
It's ME!
  • はなおか じった
  • 世界遺産の近くに住んでます。
  • Microsoft MVP for Visual Developer ASP/ASP.NET 10, 2004 - 9, 2011
広告

記事カテゴリ

書庫

日記カテゴリ

ギャラリ

その他

わんくま同盟

同郷

 

malloc の対象は char なのですが。

何かで「new と malloc は、同じ領域を、別々の方法で管理するので一緒に使ってはいけない」と、読んだ記憶が...あれれ???PlatformSDK の、HeapAlloc はどうなんだろう?

で、google で「"C++" new malloc」を検索してみたのですが、「malloc を使う必要はない」とか、「new と malloc を同一視してはいけない」というページは多々あるものの、「一緒に使ってはいけない」という記事はない。

malloc だとコンストラクタが走らないとか、そういうことを記憶違いしていたのかなぁ???

投稿日時 : 2007年1月9日 21:56
コメント
  • # re: C++ って、new と malloc を共存させていいの?
    επιστημη
    Posted @ 2007/01/09 22:52
    mallocしたのをdeleteするな
    newしたのをfreeするな
    って意味で「一緒に使うな」だったらわかるんすけどね。
  • # re: C++ って、new と malloc を共存させていいの?
    Blue
    Posted @ 2007/01/10 1:00
    MFCは、mallocとnewが普通に混在しているようなんだけど。
  • # re: C++ って、new と malloc を共存させていいの?
    恣意の
    Posted @ 2007/01/10 1:36
    というか、"一緒に使ってはいけない"だと、
    CとC++が混在するソースを扱ってる奴は死んじゃうような

    >mallocしたのをdeleteするな
    >newしたのをfreeするな
    やっぱりこれを思い違いしたんだと思います
  • # re: C++ って、new と malloc を共存させていいの?
    bear.mini
    Posted @ 2007/01/10 12:42
    私も同じプログラムの中で new と malloc() を併用してはいけないという経験則を持っていた時期がありました。
    # 同様の経験則として「std::cout と printf() を
    # 併用するとコンソール出力がうまくいかない」という
    # のもありました。
    # Borland の C++ コンパイラの結構古いバージョンを
    # 使っていたころだったかなぁ。

    その後、VC++ 7 とか 7.1 のランタイムのソースを見たとき、グローバルな operator new() を実装するために内部で malloc() を使っていたのを目にして「一緒に使っても大丈夫そうだな」と思ったような記憶があります。
  • # re: C++ って、new と malloc を共存させていいの?
    Jitta
    Posted @ 2007/01/10 19:43
    επιστημηさん、Blueさん、恣意のさん、コメントありがとうございます。

     むぅ。。。やはり思い違いの線が濃厚ですね。いや、安心しました。ありがとうございます。


    bear.miniさん、コメントありがとうございます。

    > # Borland の C++ コンパイラの結構古いバージョンを
    …あはは。私も、Borland C++ ユーザです。BC++ が、特殊だったのだろうか?
  • # re: C++ って、new と malloc を共存させていいの?
    とっちゃん
    Posted @ 2007/01/11 11:54
    new/delete malloc/free で使ってる分には、同居可能ですね。
    ヒープメモリーの扱いは、常に対になるアロケータセットを利用している限り問題になることはありません。
    実装に依存とかもないはずですが、混同はだめです。
    たとえ、実装上問題がないとしても...です。
    #new や delete は malloc/free に言語レベルで呼び出しコードを追加するため

    HeapAlloc などのAPIについても、対になるAPI(HeapAllocならHeapFreeなど)を使っていれば同居可能です。

    コンソール関係では、stdio 系(coutはこれと同じ)と、conio 系を一緒に使ってはダメというのはありますね。

    stdio 系は、CRT側のストリームキャッシュがいるので、大変な事態になります。
    ま、せいぜいでも取りこぼし程度というのはありますがw
    特にインプット系(getchar() と _getch()を同時利用とか)では注意が必要です。
    #9x系とNT系で動作が違うというのもあるんですがねw

    GUI/CUIに限らず入出力系統は同一にするというのはありますけどねw
  • # re: C++ って、new と malloc を共存させていいの?
    new
    Posted @ 2007/11/25 8:06
    動作はするかもしれないけど、あまり薦められません。
    Cの関数と連帯する場合以外は基本的にnew演算子を使うほうがいいと思います。
    _getch()とgetchar()を混同して大変な動作をしたことがあるのでわかるのですが、共存させる場合は特に注意が必要です。
  • # Your means of telling the whole thing in this paragraph is really good, all be able to without difficulty know it, Thanks a lot.
    Your means of telling the whole thing in this para
    Posted @ 2019/05/02 17:49
    Your means of telling the whole thing in this paragraph is really good, all be able to without difficulty know it, Thanks a lot.
  • # I visited multiple websites however the audio feature for audio songs current at this site is really wonderful.
    I visited multiple websites however the audio feat
    Posted @ 2019/05/08 15:08
    I visited multiple websites however the audio feature for audio songs current at this site is really
    wonderful.
  • # Link exchange is nothing else however it is only placing the other person's web site link on your page at proper place and other person will also do similar in favor of you.
    Link exchange is nothing else however it is only p
    Posted @ 2019/07/23 19:04
    Link exchange is nothing else however it is only placing the other person's web site link on your page at proper
    place and other person will also do similar in favor
    of you.
  • # Link exchange is nothing else however it is only placing the other person's web site link on your page at proper place and other person will also do similar in favor of you.
    Link exchange is nothing else however it is only p
    Posted @ 2019/07/23 19:05
    Link exchange is nothing else however it is only placing the other person's web site link on your page at proper
    place and other person will also do similar in favor
    of you.
  • # Link exchange is nothing else however it is only placing the other person's web site link on your page at proper place and other person will also do similar in favor of you.
    Link exchange is nothing else however it is only p
    Posted @ 2019/07/23 19:07
    Link exchange is nothing else however it is only placing the other person's web site link on your page at proper
    place and other person will also do similar in favor
    of you.
  • # Link exchange is nothing else however it is only placing the other person's web site link on your page at proper place and other person will also do similar in favor of you.
    Link exchange is nothing else however it is only p
    Posted @ 2019/07/23 19:08
    Link exchange is nothing else however it is only placing the other person's web site link on your page at proper
    place and other person will also do similar in favor
    of you.
  • # Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that, so at this time me also commenting here.
    Ahaa, its fastidious discussion about this piece o
    Posted @ 2019/08/24 0:37
    Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that,
    so at this time me also commenting here.
  • # Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that, so at this time me also commenting here.
    Ahaa, its fastidious discussion about this piece o
    Posted @ 2019/08/24 0:38
    Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that,
    so at this time me also commenting here.
  • # Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that, so at this time me also commenting here.
    Ahaa, its fastidious discussion about this piece o
    Posted @ 2019/08/24 0:40
    Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that,
    so at this time me also commenting here.
  • # Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that, so at this time me also commenting here.
    Ahaa, its fastidious discussion about this piece o
    Posted @ 2019/08/24 0:41
    Ahaa, its fastidious discussion about this piece of writing at this place at this weblog, I have read all that,
    so at this time me also commenting here.
  • # Ahaa, its fastidious discussion regarding this piece of writing here at this webpage, I have read all that, so at this time me also commenting at this place.
    Ahaa, its fastidious discussion regarding this pie
    Posted @ 2019/09/05 19:24
    Ahaa, its fastidious discussion regarding this piece of writing here at this webpage, I have read
    all that, so at this time me also commenting at this place.
  • # You actually make it appear really easy together with your presentation but I in finding this topic to be really one thing that I feel I might by no means understand. It kind of feels too complicated and extremely extensive for me. I am having a look fo
    You actually make it appear really easy together w
    Posted @ 2019/09/09 5:59
    You actually make it appear really easy together with your presentation but I in finding this
    topic to be really one thing that I feel I might by no means understand.
    It kind of feels too complicated and extremely extensive
    for me. I am having a look forward for your next publish, I'll attempt to get the dangle of it!
  • # re: C++ ???new ? malloc ??????????
    whats hcq
    Posted @ 2021/07/23 20:36
    chloroquine side effects https://chloroquineorigin.com/# what is hydroxychloroquine used to treat
  • # Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
    Thankfulness to my father who told me regarding th
    Posted @ 2021/12/20 16:28
    Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
  • # Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
    Thankfulness to my father who told me regarding th
    Posted @ 2021/12/20 16:29
    Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
  • # Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
    Thankfulness to my father who told me regarding th
    Posted @ 2021/12/20 16:29
    Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
  • # Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
    Thankfulness to my father who told me regarding th
    Posted @ 2021/12/20 16:30
    Thankfulness to my father who told me regarding this webpage, this webpage is truly remarkable.
  • # Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist of fate did not came about earlier! I bookmarked it.
    Helpful info. Lucky me I found your web site by ac
    Posted @ 2022/01/09 4:03
    Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist
    of fate did not came about earlier! I bookmarked it.
  • # Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist of fate did not came about earlier! I bookmarked it.
    Helpful info. Lucky me I found your web site by ac
    Posted @ 2022/01/09 4:04
    Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist
    of fate did not came about earlier! I bookmarked it.
  • # Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist of fate did not came about earlier! I bookmarked it.
    Helpful info. Lucky me I found your web site by ac
    Posted @ 2022/01/09 4:04
    Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist
    of fate did not came about earlier! I bookmarked it.
  • # Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist of fate did not came about earlier! I bookmarked it.
    Helpful info. Lucky me I found your web site by ac
    Posted @ 2022/01/09 4:05
    Helpful info. Lucky me I found your web site by accident, and I am stunned why this twist
    of fate did not came about earlier! I bookmarked it.
  • # EvUxBFiAKrKozcbtqgf
    johnansog
    Posted @ 2022/04/19 10:07
    http://imrdsoacha.gov.co/silvitra-120mg-qrms
  • # finasteride generic https://finasteridemen.com/
    Finasteride
    Posted @ 2022/05/11 23:50
    finasteride generic https://finasteridemen.com/
  • # hxtsiygxyggf
    cdcfaifa
    Posted @ 2022/05/18 23:16
    erythromycin ophthalmic ointment usp 0.5 http://erythromycin1m.com/#
  • # Hi, its fastidious article concerning media print, we all be aware of media is a enormous source of data.
    Hi, its fastidious article concerning media print,
    Posted @ 2022/12/03 17:54
    Hi, its fastidious article concerning media print, we all be aware of media is a enormous source of data.
  • # hydroxychloroquine sulfate 200mg
    MorrisReaks
    Posted @ 2022/12/26 0:17
    http://www.hydroxychloroquinex.com/ hydroxychloroquine and covid
  • # doors2.txt;1
    qIjxFRSfwy
    Posted @ 2023/03/14 15:36
    doors2.txt;1
  • # gel per erezione in farmacia https://viasenzaricetta.com/#
    ViaSenza
    Posted @ 2023/04/16 14:30
    gel per erezione in farmacia https://viasenzaricetta.com/#
  • # prednisone nz https://prednisonepills.pro/# - prednisone price south africa
    Prednisone
    Posted @ 2023/06/05 1:37
    prednisone nz https://prednisonepills.pro/# - prednisone price south africa
  • # ed treatments https://edpill.pro/# - new treatments for ed
    EdPills
    Posted @ 2023/06/27 16:03
    ed treatments https://edpill.pro/# - new treatments for ed
  • # ルイ ヴィトン リメイク ds
    xjeinmyltow@nifty.com
    Posted @ 2023/07/08 21:20
    迅速、かつ丁寧な梱包・対応をしてくださるお店です。
    今回、愛着のあるバッグの色違いを見つけてしまい即買いしました。
    新品でなければ手に入らないものもあるので、
    これからも利用したいと思います。
    ルイ ヴィトン リメイク ds https://www.b2kopi.com/product/detail.aspx?id=3489
  • # What's up i am kavin, its my first occasion to commenting anyplace, when i read this article i thought i could also create comment due to this sensible piece of writing.
    What's up i am kavin, its my first occasion to com
    Posted @ 2023/10/05 15:40
    What's up i am kavin, its my first occasion to commenting
    anyplace, when i read this article i thought i could also create comment due to
    this sensible piece of writing.
  • # Spot on with this write-up, I honestly believe that this website needs far more attention. I'll probably be returning to read through more, thanks for the advice!
    Spot on with this write-up, I honestly believe tha
    Posted @ 2023/10/23 5:18
    Spot on with this write-up, I honestly believe that this website needs far
    more attention. I'll probably be returning to read through
    more, thanks for the advice!
  • # where to buy valtrex https://valtrex.auction/ generic for valtrex
    Valtrex
    Posted @ 2023/10/24 23:45
    where to buy valtrex https://valtrex.auction/ generic for valtrex
  • # Paxlovid over the counter https://paxlovid.bid/ paxlovid price
    Paxlovid
    Posted @ 2023/10/26 0:38
    Paxlovid over the counter https://paxlovid.bid/ paxlovid price
  • # buy doxycycline online 270 tabs https://doxycycline.forum/ cheap doxycycline online
    Doxycycline
    Posted @ 2023/11/25 14:40
    buy doxycycline online 270 tabs https://doxycycline.forum/ cheap doxycycline online
  • # abella danger filmleri https://abelladanger.online/ Abella Danger
    Adella
    Posted @ 2024/03/06 11:18
    abella danger filmleri https://abelladanger.online/ Abella Danger
  • # sweetie fox https://sweetiefox.pro/ - sweetie fox
    SwitieFox
    Posted @ 2024/03/06 22:39
    sweetie fox https://sweetiefox.pro/ - sweetie fox
タイトル  
名前  
Url
コメント