Git附件与GitHub?(Git Annex with GitHub?)
我对git-annex不是很熟悉。 我刚刚阅读了文档,试图了解它。 我想到的思想,我无法确定的是:我可以在GitHub上托管一个git回购,并使用git和git附件将它推入其中,然后设置git附件以便它推动二进制文件喜欢一个S3桶,所有的源代码文件去GitHub?
I'm not very familiar with git-annex. I've just been reading the documentation trying to get my mind around it. The thought that has come to my mind, which I can't find certainty of is: Could I host a git repo on GitHub, and git push to it with git and git annex, but then set up git annex so that it pushes the binary files to like an S3 bucket, and all the source code files go to GitHub?
原文:https://stackoverflow.com/questions/29160241
最满意答案
让我们说返回的数组大小为8,它在内存中看起来像这样:
+---+ | c | +---+ | v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+(里面的数字是索引。)
现在,如果你创建一个新的变量
e
指向c + size
,它将指向一个超出数据末尾的变量:+---+ +---+ | c | | e | +---+ +---+ | | v v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+如果你从
e
减去1
它现在指向索引7
:+---+ +---+ | c | | e | +---+ +---+ | | v v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+如果你减去两个(总共)
e
将指向索引6
,减去3
并且e
将指向索引5
并且减去4
并且指向的索引将是4
。 如果你减去5
,指针e
将指向索引3
:+---+ +---+ | c | | e | +---+ +---+ | | v v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+而且距离结尾不是四个字节,距离结尾的五个字节。
所以你应该这样做
char* end = c + size - 4; /* Subtract by 4 and not 5 */
如果数据来自其他系统,例如通过Internet,您还应该注意字节顺序 。
Lets say the returned array is of size 8, it would look something like this in memory:
+---+ | c | +---+ | v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+(The numbers inside is the indexes.)
Now if you make a new variable
e
to point atc + size
it will point point to one beyond the end of the data:+---+ +---+ | c | | e | +---+ +---+ | | v v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+If you subtract
1
frome
it now points to index7
:+---+ +---+ | c | | e | +---+ +---+ | | v v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+If you subtract two (in total)
e
would point to index6
, subtract3
ande
would be pointing at index5
and subtract4
and the index pointed to would be4
. If you subtract5
the pointere
would point to index3
:+---+ +---+ | c | | e | +---+ +---+ | | v v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+And that's not four bytes from the end, that's five bytes from the end.
So you should be doing e.g.
char* end = c + size - 4; /* Subtract by 4 and not 5 */
You should also be careful of the endianness, if the data comes from other systems e.g. over the Internet.
相关问答
更多-
指向char数组的指针(Pointer to char array)[2023-04-19]
您正在更改程序中的随机内存位置。 这是未定义的行为 ,它可能会对您的程序产生随机影响,例如分段错误。 You are changing a random memory location in your program. This is undefined behavior and it could have random effects on your program such as a segmentation fault. -
char *浮动*(char* to float*)[2022-01-24]
“限制”不是C89,只有C99。 sizeof(float)可以!= 4在几台机器上。 此解决方案独立于sizeof(float),适用于所有ANSI C环境,并返回“float”中成功导入的浮动数。 int chars_to_floats(const char *chars, float *floats, int len) { int converted = 0; float *fp = (float*)chars; while( len >= sizeof*fp ) { *flo ... -
您需要以8个符号为一组拆分数组,并将每个组从二进制字符串表示转换为unsigned char。 例如: unsigned char byte = 0; for( int i = 0; i < 8; ++i ) if( a[i] == '1' ) byte |= 1 << (7-i); 然后将该字节放入另一个数组大小72/8并将其存储到文件中,例如通过std::ostream::write()方法。 您可以将位分组为16位,32位或64位,并使用uint16_t , uint32_t或uint64_ ...
-
malloc使用4个字节的char(malloc using 4 bytes for char)[2022-05-10]
内存分配取决于平台/编译器。 malloc唯一确保的是它为你所要求的内容分配足够的内存 ,仅此而已。 由于内存对齐 ,无法保证您的地址是连续的 此外,您ints代码的大小分配而不是char 。 这很可能是您看到NUM_OF_CHARS*4差异的原因,而剩余差异可归因于填充。 Memory allocation is platform/compiler dependent. The only thing malloc ensures is that it allocates enough memory for ... -
您希望使用相同的数据类型写入和读取内存。 因此,如果您的图像存储为int,请使用int *写入数据结构并使用int *从数据结构中读取。 然后在最后一刻,将数据转换为double(而不是转换指针)。 You want to write and read the memory using the same data type. So if your image is stored as ints, use int* to write to your data structure and use int* to ...
-
让我们说返回的数组大小为8,它在内存中看起来像这样: +---+ | c | +---+ | v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+ (里面的数字是索引。) 现在,如果你创建一个新的变量e指向c + size ,它将指向一个超出数据末尾的变量: +---+ +---+ ...
-
为什么失败? 你在这里有一个错字。 std::cout<<(*((*double)number))<<" is my number.\n"; 它应该是: std::cout<<(*((double*)number))<<" is my number.\n"; 我该怎么办? 您可以减少使用的括号的数量。 std::cout<< *(double*)number <<" is my number.\n"; 你应该使用C ++类型转换而不是C类型转换,所以你很清楚你在做什么。 std::cout<< *re ...
-
Char数组到一个类(Char array to a class)[2022-03-08]
正如乔恩所说,目前尚不清楚,你需要什么。 也许你在谈论也许它是二元序列化你在寻找什么? As Jon mentioned, it's not clear, what you need. Maybe you are talking about maybe it is Binary serialization what you are looking for? -
从字节的char []获取int(Get int from char[] of bytes)[2022-10-31]
你需要像这样施放它: int foo = *((int *) &buffer[0x8]); 它将首先将该点投射到一个int指针并将其解引用到int本身。 [注意不同机器类型的字节顺序; 有些做高字节首先有些做低] 为了确保这个例子很好理解,下面的代码展示了结果: #includemain() { char buffer[14] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13 }; int foo = *((int *) &buffer[0x8 ... -
如何知道传递给函数的char数组的大小(以字节为单位)?(How to know the size (in bytes) of a char array passed to a function?)[2022-11-22]
当一个数组传递给一个函数时,实际发生的是传递一个指向数组中第一个元素的指针。 换句话说,数组衰减成指向第一个元素的指针。 在这两个声明中: void test (char arrayT[]); void test2 (char *arrayU); 由于这种衰减, arrayT和arrayU的类型完全相同,而sizeof将为两者返回相同的值,即char *的大小。 将上述内容与此对比: char array1[] = "a string"; char *array2; 其中array1实际上是一个大小为9 ...