{"action":"opened","issue":{"url":"https://api.github.com/repos/csound/csound/issues/1035","repository_url":"https://api.github.com/repos/csound/csound","labels_url":"https://api.github.com/repos/csound/csound/issues/1035/labels{/name}","comments_url":"https://api.github.com/repos/csound/csound/issues/1035/comments","events_url":"https://api.github.com/repos/csound/csound/issues/1035/events","html_url":"https://github.com/csound/csound/issues/1035","id":365124243,"node_id":"MDU6SXNzdWUzNjUxMjQyNDM=","number":1035,"title":"add tabensure / array ensure to the api","user":{"login":"gesellkammer","id":81332,"node_id":"MDQ6VXNlcjgxMzMy","avatar_url":"https://avatars3.githubusercontent.com/u/81332?v=4","gravatar_id":"","url":"https://api.github.com/users/gesellkammer","html_url":"https://github.com/gesellkammer","followers_url":"https://api.github.com/users/gesellkammer/followers","following_url":"https://api.github.com/users/gesellkammer/following{/other_user}","gists_url":"https://api.github.com/users/gesellkammer/gists{/gist_id}","starred_url":"https://api.github.com/users/gesellkammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gesellkammer/subscriptions","organizations_url":"https://api.github.com/users/gesellkammer/orgs","repos_url":"https://api.github.com/users/gesellkammer/repos","events_url":"https://api.github.com/users/gesellkammer/events{/privacy}","received_events_url":"https://api.github.com/users/gesellkammer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-29T11:28:30Z","updated_at":"2018-09-29T11:28:30Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I keep copying this function for each opcode which needs to deal with arrays, and I see the same function, with slight variations, sprinkled along the codebase. Could it be possible to add it to the api? For reference, this is the version I am using:\r\n\r\n```c\r\nstatic inline void\r\narrayensure(CSOUND *csound, ARRAYDAT *p, int size) {\r\n    if (p->data==NULL || p->dimensions == 0 ||\r\n        (p->dimensions==1 && p->sizes[0] < size)) {\r\n        size_t ss;\r\n        if (p->data == NULL) {\r\n            CS_VARIABLE* var = p->arrayType->createVariable(csound, NULL);\r\n            p->arrayMemberSize = var->memBlockSize;\r\n        }\r\n        ss = p->arrayMemberSize*size;\r\n        if (p->data==NULL)\r\n            p->data = (MYFLT*)csound->Calloc(csound, ss);\r\n        else\r\n            p->data = (MYFLT*) csound->ReAlloc(csound, p->data, ss);\r\n        p->dimensions = 1;\r\n        p->sizes    = (int*)csound->Malloc(csound, sizeof(int));\r\n        p->sizes[0] = size;\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"gesellkammer"}}