需要分配比size_t更多的空间 [英] Need to Allocate more space than size_t

查看:96
本文介绍了需要分配比size_t更多的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计

我有一个特殊的问题。我必须在系统上分配超过size_t

的连续字节。在我做了一个malloc之后..我无法

做一个realloc,因为它需要size_t作为新的大小而不是

增量大小..

你能告诉我使用哪个库/系统调用..

Plz考虑到这种操作的所有物理硬件需求

可用...我知道这听起来很疯狂......但是请帮帮我这个

....

先谢谢

Rahul

hi folks
i have a peculiar problem. i have to allocate more than size_t
consequtive bytes on a system . after i do a malloc .. i am unable to
do a realloc because it takes size_t as a new size and not as an
incremental size..
can you tell me which library/system call to use..
Plz consider that all the physical hardware req for such an operation
is available... i know this sounds crazy... but just help me out here
....
Thanks in Advance
Rahul

推荐答案



i有一个特殊的问题。我必须在系统上分配超过size_t

的连续字节。我做了一个malloc ..我无法
i have a peculiar problem. i have to allocate more than size_t
consequtive bytes on a system . after i do a malloc .. i am unable to



连续字节和动态分配???


consequtive bytes and dynamic allocation ???


ra ******** ***********@gmail.com 写道:

嗨伙计

i有一个特殊的问题。我必须在系统上分配超过size_t

的连续字节。在我做了一个malloc之后..我无法

做一个realloc,因为它需要size_t作为新的大小而不是

增量大小..

你能告诉我使用哪个库/系统调用..
hi folks
i have a peculiar problem. i have to allocate more than size_t
consequtive bytes on a system . after i do a malloc .. i am unable to
do a realloc because it takes size_t as a new size and not as an
incremental size..
can you tell me which library/system call to use..



这可能是徘徊在off-topic for comp.lang.c中 - 标准语言中没有




你必须深入研究O / S才能做到这一点,如果它完全可以。

在类似非x的系统上,brk()或sbrk()调用可能是相关的
,或内存映射调用(mmap())但是...


你实际上能够处理的内存多于size_t可以表示吗?

您将受到限制,例如

可寻址性等问题。如果您正在使用32位O / S,那么例如,你不能为
(AFAIK)提供超过4Gb的地址空间。

This is probably wandering into "Off-topic for comp.lang.c" - there''s
no way in the standard language.

You''d have to delve into the O/S to do this, if it is possible at all.
On un*x-like systems the "brk()" or "sbrk()" calls are probably
relevant, or the memory-mapping calls (mmap()) but...

Are you actually able to deal with more memory than size_t can denote?
You will be limited, one way or another by issues such as
addressability.. If you are working on a 32-bit O/S, then you cannot
(AFAIK) have more than 4Gb of address space for a process, for example.


Plz考虑所有物理硬件需要这样的操作

可用...
Plz consider that all the physical hardware req for such an operation
is available...



但是如果O / S不能访问超过size_t可以表示,那根本没有帮助

..

But if the O/S can''t access more than size_t can denote, that''s no help
at all..


i知道这听起来很疯狂......但只是帮助我这里
i know this sounds crazy... but just help me out here



您可能需要向我们提供更多信息,但我们可能会在与您的平台相关的新闻组中指出

...

You probably need to give us more information, but we''ll probably point
you at a newsgroup relating to your platform...


" ra*******************@gmail.com" < ra ******************* @ gmail.com>

写道:
"ra*******************@gmail.com" <ra*******************@gmail.com>
wrote:

i有一个特殊的问题。我必须在系统上分配超过size_t

的连续字节。在我做了一个malloc之后..我无法

做一个realloc,因为它需要size_t作为新的大小而不是

增量大小..

你能告诉我使用哪个库/系统调用..
i have a peculiar problem. i have to allocate more than size_t
consequtive bytes on a system . after i do a malloc .. i am unable to
do a realloc because it takes size_t as a new size and not as an
incremental size..
can you tell me which library/system call to use..



没有。如果你需要的内存超过

size_t中指定的内存,ISO C将无法执行此操作。理想情况下,这甚至不应该是b
;你的实现应该使size_t足够大,以便为每个可能的内存块大小提供



Richard

There isn''t any. If you need more memory than can be specified in a
size_t, ISO C gives you no way to do so. Ideally, this shouldn''t even be
possible; your implementation should make size_t large enough to cater
for every possible memory block size.

Richard


这篇关于需要分配比size_t更多的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆