avatar
重铺草皮# Living
p*3
1
看到前面人post了这样一个问题,所以顺便问一问
const char* copy(const char* src, char* dest, int n)
一般的做法是用一个wrapper来保护字符串。因为直接传来的是指针,好像没办法这么
做,应为src随时都可以在被copy的时候被修改。
是不是可以copy以后然后再对比copy后的memory和src是不是每个byte一样的,不一样
再retry?? 不过好像也不行
avatar
s*1
2
如果用翻地机的话,会不会损坏地下喷水系统?
avatar
p*3
3
看到前面人post了这样一个问题,所以顺便问一问
const char* copy(const char* src, char* dest, int n)
一般的做法是用一个wrapper来保护字符串。因为直接传来的是指针,好像没办法这么
做,应为src随时都可以在被copy的时候被修改。
是不是可以copy以后然后再对比copy后的memory和src是不是每个byte一样的,不一样
再retry?? 不过好像也不行
avatar
u*q
4
把tiller深度设置6-12"。
avatar
f*p
5
搜了一下,https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/
yBrUjgvGwf8 里面有一个回复我觉得挺不错,大家来说说怎样
Much better to allocate a block of storage (either a general "new" or
your own sub-allocator), copy the string into it, pass it to the recipient,
and let the
recipient release it (either delete or your own deallocation back to your
pool of
buffers). This means that there is never more than one thread, ever, using
the storage.
You do not protect the function; you protect the area it is copying into.
And again, only
if there really is concurrent access possible. strcpy is reentrant, meaning
that there is
no reason to restrict the threads to doing only one strcpy at a time; but
you must make
sure the buffer is either unique to the thread during the time of copy, or
IT (not the
strcpy function) is protected against concurrent access.
If you guarantee that the other thread cannot possibly see the string until
it has been
copied, it doesn't matter. strcpy can be used concurrently by many threads
to copy into
disjoint string buffers. But if there is any possibility of concurrent
access, you have to
provide explicit synchronization yourself.
You might want to read my essays on multithreading and on producer/consumer
structures
using semaphores on my MVP Tips site.

【在 p*****3 的大作中提到】
: 看到前面人post了这样一个问题,所以顺便问一问
: const char* copy(const char* src, char* dest, int n)
: 一般的做法是用一个wrapper来保护字符串。因为直接传来的是指针,好像没办法这么
: 做,应为src随时都可以在被copy的时候被修改。
: 是不是可以copy以后然后再对比copy后的memory和src是不是每个byte一样的,不一样
: 再retry?? 不过好像也不行

avatar
L*r
6
copy src to an immutableList, then copy from immutableList to dest.

【在 p*****3 的大作中提到】
: 看到前面人post了这样一个问题,所以顺便问一问
: const char* copy(const char* src, char* dest, int n)
: 一般的做法是用一个wrapper来保护字符串。因为直接传来的是指针,好像没办法这么
: 做,应为src随时都可以在被copy的时候被修改。
: 是不是可以copy以后然后再对比copy后的memory和src是不是每个byte一样的,不一样
: 再retry?? 不过好像也不行

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。