Hi everybody,
I am developing a low level solution by using named pipes with dynamic memory allocation with CodeBridge. For this I have been using the library directly but after the execution returns to the main Cobol program, when I use SET statement with a LINKAGE structure it gives me an error 104.
The specific question is, if I am using a Cobol POINTER as a C argument for memory allocation, should PointerBaseToCobol, PointerOffsetToCobol and PointerSizeToCobol functions be enough? Or Should I use something else?
Greetings!
Marcos
#CodeBridge#pointers#memoryallocation#RMCOBOLI'm sure you're just using short hand, but "COBOL pointer as a C argument" wouldn't work. A more correct statement would be that a COBOL pointer data item may be passed to or from a C program using the CodeBridge library to interface with a C pointer data item. If the memory you wish to reference in the COBOL program is allocated/owned by the C program and referenced by a C pointer data item, then PointerBaseToCobol, PointerOffsetToCobol and PointerSizeToCobol functions allow you to return that C pointer data item as a COBOL pointer data item to your COBOL program. Please note that those three functions do not do any memory allocation themselves. Also, the C program is responsible for freeing the allocated memory in this case because it owns the memory and further must not free the memory until the COBOL program is done referencing the memory through the COBOL pointer data item.
You say "when I use SET statement with a LINKAGE structure it gives me an error 104" I must again assume this is short hand. The SET statement wouldn't cause a 104 error (see documentation in User's Guide for error 104) unless the pointer data item referenced in the SET statement is inside a linkage section data item that doesn't have a valid base address. The 104 error generally happens when a linkage section record is actually referenced, not when setting the linkage section record's base address. The 104 error could be the result of not actually allocating any memory in your C program or incorrectly describing that memory when using the PointerBaseToCobol, PointerOffsetToCobol and PointerSizeToCobol functions to return a COBOL pointer to the memory for use by the COBOL program. More detail would be needed to know the cause of your 104 error.
Hi everybody,
I am developing a low level solution by using named pipes with dynamic memory allocation with CodeBridge. For this I have been using the library directly but after the execution returns to the main Cobol program, when I use SET statement with a LINKAGE structure it gives me an error 104.
The specific question is, if I am using a Cobol POINTER as a C argument for memory allocation, should PointerBaseToCobol, PointerOffsetToCobol and PointerSizeToCobol functions be enough? Or Should I use something else?
Greetings!
Marcos
#CodeBridge#pointers#memoryallocation#RMCOBOLI'm sure you're just using short hand, but "COBOL pointer as a C argument" wouldn't work. A more correct statement would be that a COBOL pointer data item may be passed to or from a C program using the CodeBridge library to interface with a C pointer data item. If the memory you wish to reference in the COBOL program is allocated/owned by the C program and referenced by a C pointer data item, then PointerBaseToCobol, PointerOffsetToCobol and PointerSizeToCobol functions allow you to return that C pointer data item as a COBOL pointer data item to your COBOL program. Please note that those three functions do not do any memory allocation themselves. Also, the C program is responsible for freeing the allocated memory in this case because it owns the memory and further must not free the memory until the COBOL program is done referencing the memory through the COBOL pointer data item.
You say "when I use SET statement with a LINKAGE structure it gives me an error 104" I must again assume this is short hand. The SET statement wouldn't cause a 104 error (see documentation in User's Guide for error 104) unless the pointer data item referenced in the SET statement is inside a linkage section data item that doesn't have a valid base address. The 104 error generally happens when a linkage section record is actually referenced, not when setting the linkage section record's base address. The 104 error could be the result of not actually allocating any memory in your C program or incorrectly describing that memory when using the PointerBaseToCobol, PointerOffsetToCobol and PointerSizeToCobol functions to return a COBOL pointer to the memory for use by the COBOL program. More detail would be needed to know the cause of your 104 error.